diff options
62 files changed, 2558 insertions, 0 deletions
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.classpath b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.classpath new file mode 100644 index 000000000..64c5e31b7 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.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"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.project b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.project new file mode 100644 index 000000000..1646bc9ad --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.p2.examples.rcp.prestartupdate</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> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..337c4649f --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Mar 16 12:12:08 PDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +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 diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF new file mode 100644 index 000000000..15c04b5f9 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Prestartupdate +Bundle-SymbolicName: org.eclipse.equinox.p2.examples.rcp.prestartupdate; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: org.eclipse.equinox.p2.examples.rcp.prestartupdate.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.equinox.p2.metadata;bundle-version="1.0.0", + org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0", + org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.0", + org.eclipse.equinox.p2.extensionlocation;bundle-version="1.0.0", + org.eclipse.equinox.p2.updatesite;bundle-version="1.0.0", + org.eclipse.equinox.p2.director;bundle-version="1.0.100", + org.eclipse.equinox.p2.engine;bundle-version="1.0.100", + org.eclipse.equinox.p2.core;bundle-version="1.0.100", + org.eclipse.ecf;bundle-version="3.0.0", + org.eclipse.ecf.filetransfer;bundle-version="3.0.0", + org.eclipse.ecf.identity;bundle-version="3.0.0", + org.eclipse.ecf.provider.filetransfer;bundle-version="3.0.0", + org.eclipse.ecf.provider.filetransfer.httpclient;bundle-version="3.0.0", + org.apache.commons.codec;bundle-version="1.3.0", + org.apache.commons.httpclient;bundle-version="3.1.0" +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/build.properties b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/build.properties new file mode 100644 index 000000000..bb0913764 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + product_lg.gif,\ + splash.bmp
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/mail.ico b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/mail.ico Binary files differnew file mode 100644 index 000000000..b00006113 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/mail.ico diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample.gif b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample.gif Binary files differnew file mode 100644 index 000000000..34fb3c9d8 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample.icns b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample.icns Binary files differnew file mode 100644 index 000000000..1e92ccce1 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample.icns diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample2.gif b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample2.gif Binary files differnew file mode 100644 index 000000000..252d7ebcb --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample2.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample3.gif b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample3.gif Binary files differnew file mode 100644 index 000000000..b949ac948 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/icons/sample3.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/p2.inf b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/p2.inf new file mode 100644 index 000000000..48f31a324 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/p2.inf @@ -0,0 +1,3 @@ +instructions.configure=\ + addRepository(type:0,location:http${#58}//www.eclipse.org/equinox/p2/testing/updateSite);\ + addRepository(type:1,location:http${#58}//www.eclipse.org/equinox/p2/testing/updateSite);
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/plugin.xml b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/plugin.xml new file mode 100644 index 000000000..283ed1da8 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/plugin.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + + <extension + id="application" + point="org.eclipse.core.runtime.applications"> + <application> + <run + class="org.eclipse.equinox.p2.examples.rcp.prestartupdate.Application"> + </run> + </application> + </extension> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + name="RCP Perspective" + class="org.eclipse.equinox.p2.examples.rcp.prestartupdate.Perspective" + id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.perspective"> + </perspective> + </extension> + <extension + point="org.eclipse.ui.views"> + <view + name="Message" + allowMultiple="true" + icon="icons/sample2.gif" + class="org.eclipse.equinox.p2.examples.rcp.prestartupdate.View" + id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.view"> + </view> + <view + name="Mailboxes" + allowMultiple="true" + icon="icons/sample3.gif" + class="org.eclipse.equinox.p2.examples.rcp.prestartupdate.NavigationView" + id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.navigationView"> + </view> + </extension> + <extension + point="org.eclipse.ui.commands"> + <category + name="Mail" + id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.category"> + </category> + <command + name="Open Mailbox" + description="Opens a mailbox" + categoryId="org.eclipse.equinox.p2.examples.rcp.prestartupdate.category" + id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.open"> + </command> + <command + name="Open Message Dialog" + description="Open a message dialog" + categoryId="org.eclipse.equinox.p2.examples.rcp.prestartupdate.category" + id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.openMessage"> + </command> + </extension> + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="org.eclipse.equinox.p2.examples.rcp.prestartupdate.open" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+2"> + </key> + <key + commandId="org.eclipse.equinox.p2.examples.rcp.prestartupdate.openMessage" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+3"> + </key> + <key + commandId="org.eclipse.ui.file.exit" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+X"> + </key> + </extension> + <extension + id="product" + point="org.eclipse.core.runtime.products"> + <product + application="org.eclipse.equinox.p2.examples.rcp.prestartupdate.application" + name="RCP Product"> + <property + name="aboutText" + value="RCP Mail template created by PDE"> + </property> + <property + name="windowImages" + value="icons/sample2.gif"> + </property> + <property + name="aboutImage" + value="product_lg.gif"> + </property> + </product> + </extension> + +</plugin> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/prestartupdate.product b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/prestartupdate.product new file mode 100644 index 000000000..2133ee86d --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/prestartupdate.product @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="RCP Mail Example (Pre-Startup Example)" id="org.eclipse.equinox.p2.examples.rcp.prestartupdate.product" application="org.eclipse.equinox.p2.examples.rcp.prestartupdate.application" version="1.0.0.qualifier" useFeatures="false"> + + <aboutInfo> + <image path="product_lg.gif"/> + <text> + RCP Mail Example (Pre-Startup Example) + </text> + </aboutInfo> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <windowImages i16="icons/sample2.gif"/> + + <splash + location="org.eclipse.equinox.p2.examples.rcp.prestartupdate" /> + <launcher name="prestartupdate"> + <solaris/> + <win useIco="false"> + <bmp/> + </win> + </launcher> + + <vm> + </vm> + + <plugins> + <plugin id="com.ibm.icu"/> + <plugin id="org.apache.commons.codec"/> + <plugin id="org.apache.commons.httpclient"/> + <plugin id="org.apache.commons.logging"/> + <plugin id="org.eclipse.core.commands"/> + <plugin id="org.eclipse.core.contenttype"/> + <plugin id="org.eclipse.core.databinding"/> + <plugin id="org.eclipse.core.databinding.observable"/> + <plugin id="org.eclipse.core.databinding.property"/> + <plugin id="org.eclipse.core.expressions"/> + <plugin id="org.eclipse.core.jobs"/> + <plugin id="org.eclipse.core.runtime"/> + <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> + <plugin id="org.eclipse.ecf"/> + <plugin id="org.eclipse.ecf.filetransfer"/> + <plugin id="org.eclipse.ecf.identity"/> + <plugin id="org.eclipse.ecf.provider.filetransfer"/> + <plugin id="org.eclipse.ecf.provider.filetransfer.httpclient"/> + <plugin id="org.eclipse.ecf.provider.filetransfer.httpclient.ssl" fragment="true"/> + <plugin id="org.eclipse.ecf.provider.filetransfer.ssl" fragment="true"/> + <plugin id="org.eclipse.ecf.ssl" fragment="true"/> + <plugin id="org.eclipse.equinox.app"/> + <plugin id="org.eclipse.equinox.common"/> + <plugin id="org.eclipse.equinox.frameworkadmin"/> + <plugin id="org.eclipse.equinox.frameworkadmin.equinox"/> + <plugin id="org.eclipse.equinox.p2.artifact.repository"/> + <plugin id="org.eclipse.equinox.p2.core"/> + <plugin id="org.eclipse.equinox.p2.director"/> + <plugin id="org.eclipse.equinox.p2.directorywatcher"/> + <plugin id="org.eclipse.equinox.p2.engine"/> + <plugin id="org.eclipse.equinox.p2.examples.rcp.cloud"/> + <plugin id="org.eclipse.equinox.p2.exemplarysetup"/> + <plugin id="org.eclipse.equinox.p2.extensionlocation"/> + <plugin id="org.eclipse.equinox.p2.garbagecollector"/> + <plugin id="org.eclipse.equinox.p2.jarprocessor"/> + <plugin id="org.eclipse.equinox.p2.metadata"/> + <plugin id="org.eclipse.equinox.p2.metadata.repository"/> + <plugin id="org.eclipse.equinox.p2.publisher"/> + <plugin id="org.eclipse.equinox.p2.touchpoint.eclipse"/> + <plugin id="org.eclipse.equinox.p2.ui"/> + <plugin id="org.eclipse.equinox.p2.updatesite"/> + <plugin id="org.eclipse.equinox.preferences"/> + <plugin id="org.eclipse.equinox.registry"/> + <plugin id="org.eclipse.equinox.security"/> + <plugin id="org.eclipse.equinox.security.ui"/> + <plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/> + <plugin id="org.eclipse.equinox.simpleconfigurator"/> + <plugin id="org.eclipse.equinox.simpleconfigurator.manipulator"/> + <plugin id="org.eclipse.help"/> + <plugin id="org.eclipse.jface"/> + <plugin id="org.eclipse.jface.databinding"/> + <plugin id="org.eclipse.osgi"/> + <plugin id="org.eclipse.osgi.services"/> + <plugin id="org.eclipse.swt"/> + <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/> + <plugin id="org.eclipse.ui"/> + <plugin id="org.eclipse.ui.workbench"/> + <plugin id="org.sat4j.core"/> + <plugin id="org.sat4j.pb"/> + </plugins> + + +</product> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/product_lg.gif b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/product_lg.gif Binary files differnew file mode 100644 index 000000000..bd95e283f --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/product_lg.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/splash.bmp b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/splash.bmp Binary files differnew file mode 100644 index 000000000..d7d2e3032 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/splash.bmp diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Activator.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Activator.java new file mode 100644 index 000000000..1a8dd9585 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Activator.java @@ -0,0 +1,65 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +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 = "org.eclipse.equinox.p2.examples.rcp.prestartupdate"; + + // The shared instance + private static Activator plugin; + + // XXX Shared instance of bundle context + static BundleContext bundleContext; + + /** + * 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; + bundleContext = context; + } + + /* + * (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); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Application.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Application.java new file mode 100644 index 000000000..9eb2e7283 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Application.java @@ -0,0 +1,212 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.SubMonitor; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan; +import org.eclipse.equinox.internal.provisional.p2.engine.DefaultPhaseSet; +import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; +import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; +import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.query.Collector; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.statushandlers.StatusManager; + +/** + * This class controls all aspects of the application's execution + */ +public class Application implements IApplication { + + /* + * (non-Javadoc) + * + * @seeorg.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app. + * IApplicationContext) + */ + public Object start(IApplicationContext context) { + Display display = PlatformUI.createDisplay(); + try { + // XXX check for updates before ever running a workbench + if (checkForUpdates(display)) + // An update was done, we need to restart + return IApplication.EXIT_RESTART; + else { + int returnCode = PlatformUI.createAndRunWorkbench(display, + new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + } + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + final IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench == null) + return; + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } + + // XXX Check for updates to this application and return true if + // we have installed updates and need a restart. + // This method is intentionally long and ugly in order to provide + // "one-stop-shopping" for how to check for and perform an update. + private boolean checkForUpdates(Display display) { + // Before we show a progress dialog, at least find out that we have + // installed content and repos to check. + final IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper + .getService(Activator.bundleContext, IProfileRegistry.class + .getName()); + if (profileRegistry == null) + return false; + final IProfile profile = profileRegistry + .getProfile(IProfileRegistry.SELF); + if (profile == null) + return false; + + // We are going to look for updates to all IU's in the profile. A + // different query could be used if we are looking for updates to + // a subset. For example, the p2 UI only looks for updates to those + // IU's marked with a special property. + final Collector collector = profile.query(InstallableUnitQuery.ANY, + new Collector(), null); + if (collector.isEmpty()) + return false; + final IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper + .getService(Activator.bundleContext, + IMetadataRepositoryManager.class.getName()); + if (manager == null) + return false; + final URI[] reposToSearch = manager + .getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_ALL); + if (reposToSearch.length == 0) + return false; + final IPlanner planner = (IPlanner) ServiceHelper.getService( + Activator.bundleContext, IPlanner.class.getName()); + if (planner == null) + return false; + // Looking in all known repositories for updates for each IU in the profile + final boolean[] didWeUpdate = new boolean[1]; + didWeUpdate[0] = false; + IRunnableWithProgress runnable = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + SubMonitor sub = SubMonitor.convert(monitor, + "Checking for application updates...", 200 + (collector + .size() * 100)); + // First we look for replacement IU's for each IU + ArrayList iusWithUpdates = new ArrayList(); + ArrayList replacementIUs = new ArrayList(); + Iterator iter = collector.iterator(); + ProvisioningContext pc = new ProvisioningContext(reposToSearch); + while (iter.hasNext()) { + if (sub.isCanceled()) + throw new InterruptedException(); + IInstallableUnit iu = (IInstallableUnit) iter.next(); + IInstallableUnit[] replacements = planner.updatesFor(iu, + pc, sub.newChild(100)); + if (replacements.length > 0) { + iusWithUpdates.add(iu); + if (replacements.length == 1) + replacementIUs.add(replacements[0]); + else { + IInstallableUnit repl = replacements[0]; + for (int i = 1; i < replacements.length; i++) + if (replacements[i].getVersion().compareTo( + repl.getVersion()) > 0) + repl = replacements[i]; + replacementIUs.add(repl); + } + } + } + // Did we find any updates? + if (iusWithUpdates.size() == 0) { + sub.done(); + } else { + if (sub.isCanceled()) + throw new InterruptedException(); + // Build a profile change request + ProfileChangeRequest changeRequest = new ProfileChangeRequest( + profile); + changeRequest + .removeInstallableUnits((IInstallableUnit[]) iusWithUpdates + .toArray(new IInstallableUnit[iusWithUpdates + .size()])); + changeRequest + .addInstallableUnits((IInstallableUnit[]) iusWithUpdates + .toArray(new IInstallableUnit[iusWithUpdates + .size()])); + ProvisioningPlan plan = planner.getProvisioningPlan( + changeRequest, pc, sub.newChild(100)); + if (plan.getStatus().getSeverity() == IStatus.CANCEL) + throw new InterruptedException(); + if (plan.getStatus().getSeverity() != IStatus.ERROR) { + IEngine engine = (IEngine) ServiceHelper.getService( + Activator.bundleContext, IEngine.class + .getName()); + IArtifactRepositoryManager artifactMgr = (IArtifactRepositoryManager) ServiceHelper + .getService(Activator.bundleContext, + IArtifactRepositoryManager.class + .getName()); + if (engine != null && artifactMgr != null) { + pc + .setArtifactRepositories(artifactMgr + .getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)); + IStatus status = engine.perform(profile, + new DefaultPhaseSet(), plan.getOperands(), + pc, sub.newChild(100)); + if (status.getSeverity() == IStatus.CANCEL) + throw new InterruptedException(); + if (status.getSeverity() != IStatus.ERROR) { + didWeUpdate[0] = true; + } + } + } + } + } + }; + try { + new ProgressMonitorDialog(null).run(true, true, runnable); + } catch (InvocationTargetException e) { + e.printStackTrace(); + return false; + } catch (InterruptedException e) { + return false; + } + return didWeUpdate[0]; + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationActionBarAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationActionBarAdvisor.java new file mode 100644 index 000000000..68f0ad7c4 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationActionBarAdvisor.java @@ -0,0 +1,91 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.ICoolBarManager; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.action.ToolBarContributionItem; +import org.eclipse.jface.action.ToolBarManager; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; + +/** + * An action bar advisor is responsible for creating, adding, and disposing of the + * actions added to a workbench window. Each window will be populated with + * new actions. + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + + // Actions - important to allocate these only in makeActions, and then use them + // in the fill methods. This ensures that the actions aren't recreated + // when fillActionBars is called with FILL_PROXY. + private IWorkbenchAction exitAction; + private IWorkbenchAction aboutAction; + private IWorkbenchAction newWindowAction; + private OpenViewAction openViewAction; + private Action messagePopupAction; + + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(final IWorkbenchWindow window) { + // Creates the actions and registers them. + // Registering is needed to ensure that key bindings work. + // The corresponding commands keybindings are defined in the plugin.xml file. + // Registering also provides automatic disposal of the actions when + // the window is closed. + + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + + aboutAction = ActionFactory.ABOUT.create(window); + register(aboutAction); + + newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); + register(newWindowAction); + + openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID); + register(openViewAction); + + messagePopupAction = new MessagePopupAction("Open Message", window); + register(messagePopupAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); + + menuBar.add(fileMenu); + // Add a group marker indicating where action set menus will appear. + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(helpMenu); + + // File + fileMenu.add(newWindowAction); + fileMenu.add(new Separator()); + fileMenu.add(messagePopupAction); + fileMenu.add(openViewAction); + fileMenu.add(new Separator()); + fileMenu.add(exitAction); + + // Help + helpMenu.add(aboutAction); + } + + protected void fillCoolBar(ICoolBarManager coolBar) { + IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT); + coolBar.add(new ToolBarContributionItem(toolbar, "main")); + toolbar.add(openViewAction); + toolbar.add(messagePopupAction); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java new file mode 100644 index 000000000..d27729b67 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,21 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +/** + * This workbench advisor creates the window advisor, and specifies + * the perspective id for the initial window. + */ +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return Perspective.ID; + } + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchWindowAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 000000000..2bb795ccd --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,26 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(600, 400)); + configurer.setShowCoolBar(true); + configurer.setShowStatusLine(false); + } + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ICommandIds.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ICommandIds.java new file mode 100644 index 000000000..42a745511 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/ICommandIds.java @@ -0,0 +1,15 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +/** + * Interface defining the application's command IDs. + * Key bindings can be defined for specific commands. + * To associate an action with a command, use IAction.setActionDefinitionId(commandId). + * + * @see org.eclipse.jface.action.IAction#setActionDefinitionId(String) + */ +public interface ICommandIds { + + public static final String CMD_OPEN = "org.eclipse.equinox.p2.examples.rcp.prestartupdate.open"; + public static final String CMD_OPEN_MESSAGE = "org.eclipse.equinox.p2.examples.rcp.prestartupdate.openMessage"; + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/MessagePopupAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/MessagePopupAction.java new file mode 100644 index 000000000..2eb2ca93d --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/MessagePopupAction.java @@ -0,0 +1,25 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchWindow; + + +public class MessagePopupAction extends Action { + + private final IWorkbenchWindow window; + + MessagePopupAction(String text, IWorkbenchWindow window) { + super(text); + this.window = window; + // The id is used to refer to the action in a menu or toolbar + setId(ICommandIds.CMD_OPEN_MESSAGE); + // Associate the action with a pre-defined command, to allow key bindings. + setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE); + setImageDescriptor(org.eclipse.equinox.p2.examples.rcp.prestartupdate.Activator.getImageDescriptor("/icons/sample3.gif")); + } + + public void run() { + MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!"); + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/NavigationView.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/NavigationView.java new file mode 100644 index 000000000..77f69a28d --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/NavigationView.java @@ -0,0 +1,151 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import java.util.ArrayList; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + +public class NavigationView extends ViewPart { + public static final String ID = "org.eclipse.equinox.p2.examples.rcp.prestartupdate.navigationView"; + private TreeViewer viewer; + + class TreeObject { + private String name; + private TreeParent parent; + + public TreeObject(String name) { + this.name = name; + } + public String getName() { + return name; + } + public void setParent(TreeParent parent) { + this.parent = parent; + } + public TreeParent getParent() { + return parent; + } + public String toString() { + return getName(); + } + } + + class TreeParent extends TreeObject { + private ArrayList children; + public TreeParent(String name) { + super(name); + children = new ArrayList(); + } + public void addChild(TreeObject child) { + children.add(child); + child.setParent(this); + } + public void removeChild(TreeObject child) { + children.remove(child); + child.setParent(null); + } + public TreeObject[] getChildren() { + return (TreeObject[]) children.toArray(new TreeObject[children.size()]); + } + public boolean hasChildren() { + return children.size()>0; + } + } + + class ViewContentProvider implements IStructuredContentProvider, + ITreeContentProvider { + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + return getChildren(parent); + } + + public Object getParent(Object child) { + if (child instanceof TreeObject) { + return ((TreeObject)child).getParent(); + } + return null; + } + + public Object[] getChildren(Object parent) { + if (parent instanceof TreeParent) { + return ((TreeParent)parent).getChildren(); + } + return new Object[0]; + } + + public boolean hasChildren(Object parent) { + if (parent instanceof TreeParent) + return ((TreeParent)parent).hasChildren(); + return false; + } + } + + class ViewLabelProvider extends LabelProvider { + + public String getText(Object obj) { + return obj.toString(); + } + public Image getImage(Object obj) { + String imageKey = ISharedImages.IMG_OBJ_ELEMENT; + if (obj instanceof TreeParent) + imageKey = ISharedImages.IMG_OBJ_FOLDER; + return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); + } + } + + /** + * We will set up a dummy model to initialize tree heararchy. In real + * code, you will connect to a real model and expose its hierarchy. + */ + private TreeObject createDummyModel() { + TreeObject to1 = new TreeObject("Inbox"); + TreeObject to2 = new TreeObject("Drafts"); + TreeObject to3 = new TreeObject("Sent"); + TreeParent p1 = new TreeParent("me@this.com"); + p1.addChild(to1); + p1.addChild(to2); + p1.addChild(to3); + + TreeObject to4 = new TreeObject("Inbox"); + TreeParent p2 = new TreeParent("other@aol.com"); + p2.addChild(to4); + + TreeParent root = new TreeParent(""); + root.addChild(p1); + root.addChild(p2); + return root; + } + + /** + * This is a callback that will allow us to create the viewer and initialize + * it. + */ + public void createPartControl(Composite parent) { + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + viewer.setContentProvider(new ViewContentProvider()); + viewer.setLabelProvider(new ViewLabelProvider()); + viewer.setInput(createDummyModel()); + } + + /** + * Passing the focus request to the viewer's control. + */ + public void setFocus() { + viewer.getControl().setFocus(); + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/OpenViewAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/OpenViewAction.java new file mode 100644 index 000000000..b741fa946 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/OpenViewAction.java @@ -0,0 +1,36 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; + + +public class OpenViewAction extends Action { + + private final IWorkbenchWindow window; + private int instanceNum = 0; + private final String viewId; + + public OpenViewAction(IWorkbenchWindow window, String label, String viewId) { + this.window = window; + this.viewId = viewId; + setText(label); + // The id is used to refer to the action in a menu or toolbar + setId(ICommandIds.CMD_OPEN); + // Associate the action with a pre-defined command, to allow key bindings. + setActionDefinitionId(ICommandIds.CMD_OPEN); + setImageDescriptor(org.eclipse.equinox.p2.examples.rcp.prestartupdate.Activator.getImageDescriptor("/icons/sample2.gif")); + } + + public void run() { + if(window != null) { + try { + window.getActivePage().showView(viewId, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE); + } catch (PartInitException e) { + MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage()); + } + } + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Perspective.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Perspective.java new file mode 100644 index 000000000..244eca03c --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/Perspective.java @@ -0,0 +1,25 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class Perspective implements IPerspectiveFactory { + + /** + * The ID of the perspective as specified in the extension. + */ + public static final String ID = "org.eclipse.equinox.p2.examples.rcp.prestartupdate.perspective"; + + public void createInitialLayout(IPageLayout layout) { + String editorArea = layout.getEditorArea(); + layout.setEditorAreaVisible(false); + + layout.addStandaloneView(NavigationView.ID, false, IPageLayout.LEFT, 0.25f, editorArea); + IFolderLayout folder = layout.createFolder("messages", IPageLayout.TOP, 0.5f, editorArea); + folder.addPlaceholder(View.ID + ":*"); + folder.addView(View.ID); + + layout.getViewLayout(NavigationView.ID).setCloseable(false); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/View.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/View.java new file mode 100644 index 000000000..38be31690 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/View.java @@ -0,0 +1,77 @@ +package org.eclipse.equinox.p2.examples.rcp.prestartupdate; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.part.ViewPart; + +public class View extends ViewPart { + + public static final String ID = "org.eclipse.equinox.p2.examples.rcp.prestartupdate.view"; + + public void createPartControl(Composite parent) { + Composite top = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + top.setLayout(layout); + // top banner + Composite banner = new Composite(top, SWT.NONE); + banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); + layout = new GridLayout(); + layout.marginHeight = 5; + layout.marginWidth = 10; + layout.numColumns = 2; + banner.setLayout(layout); + + // setup bold font + Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); + + Label l = new Label(banner, SWT.WRAP); + l.setText("Subject:"); + l.setFont(boldFont); + l = new Label(banner, SWT.WRAP); + l.setText("This is a message about the cool Eclipse RCP!"); + + l = new Label(banner, SWT.WRAP); + l.setText("From:"); + l.setFont(boldFont); + + final Link link = new Link(banner, SWT.NONE); + link.setText("<a>nicole@mail.org</a>"); + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now."); + } + }); + + l = new Label(banner, SWT.WRAP); + l.setText("Date:"); + l.setFont(boldFont); + l = new Label(banner, SWT.WRAP); + l.setText("10:34 am"); + // message contents + Text text = new Text(top, SWT.MULTI | SWT.WRAP); + text.setText("This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n"+ + "- add a top-level menu and toolbar with actions\n"+ + "- add keybindings to actions\n" + + "- create views that can't be closed and\n"+ + " multiple instances of the same view\n"+ + "- perspectives with placeholders for new views\n"+ + "- use the default about dialog\n"+ + "- create a product definition\n"); + text.setLayoutData(new GridData(GridData.FILL_BOTH)); + } + + public void setFocus() { + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.classpath b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.classpath new file mode 100644 index 000000000..64c5e31b7 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.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"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.project b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.project new file mode 100644 index 000000000..b2b323f79 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility</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> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..6f414e032 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Mar 16 12:11:08 PDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +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 diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF new file mode 100644 index 000000000..bdfed2959 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/META-INF/MANIFEST.MF @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Sdkbundlevisibility +Bundle-SymbolicName: org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Activator: org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.equinox.p2.ui;bundle-version="1.0.100", + org.eclipse.equinox.p2.metadata;bundle-version="1.0.0", + org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0", + org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.0", + org.eclipse.equinox.p2.extensionlocation;bundle-version="1.0.0", + org.eclipse.equinox.p2.updatesite;bundle-version="1.0.0", + org.eclipse.equinox.p2.director;bundle-version="1.0.100", + org.eclipse.equinox.p2.engine;bundle-version="1.0.100", + org.eclipse.equinox.p2.core;bundle-version="1.0.100", + org.eclipse.ecf;bundle-version="3.0.0", + org.eclipse.ecf.filetransfer;bundle-version="3.0.0", + org.eclipse.ecf.identity;bundle-version="3.0.0", + org.eclipse.ecf.provider.filetransfer;bundle-version="3.0.0", + org.eclipse.ecf.provider.filetransfer.httpclient;bundle-version="3.0.0", + org.apache.commons.codec;bundle-version="1.3.0", + org.apache.commons.httpclient;bundle-version="3.1.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/build.properties b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/build.properties new file mode 100644 index 000000000..5c50a0005 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/build.properties @@ -0,0 +1,9 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + product_lg.gif,\ + splash.bmp,\ + plugin.properties diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/mail.ico b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/mail.ico Binary files differnew file mode 100644 index 000000000..b00006113 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/mail.ico diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample.gif b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample.gif Binary files differnew file mode 100644 index 000000000..34fb3c9d8 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample.icns b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample.icns Binary files differnew file mode 100644 index 000000000..1e92ccce1 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample.icns diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample2.gif b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample2.gif Binary files differnew file mode 100644 index 000000000..252d7ebcb --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample2.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample3.gif b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample3.gif Binary files differnew file mode 100644 index 000000000..b949ac948 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/icons/sample3.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/p2.inf b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/p2.inf new file mode 100644 index 000000000..48f31a324 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/p2.inf @@ -0,0 +1,3 @@ +instructions.configure=\ + addRepository(type:0,location:http${#58}//www.eclipse.org/equinox/p2/testing/updateSite);\ + addRepository(type:1,location:http${#58}//www.eclipse.org/equinox/p2/testing/updateSite);
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/plugin.properties b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/plugin.properties new file mode 100644 index 000000000..2dee9a537 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/plugin.properties @@ -0,0 +1,23 @@ +############################################################################### +# Copyright (c) 2009 IBM Corporation and others. +# 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: +# IBM Corporation - initial API and implementation +############################################################################### +# +# RCP Mail Plug-in Resources +# +Update.command=Check for Updates +Update.command.mnemonic=U +Install.command=Install New Software... +Install.command.mnemonic=S +provisioningPrefPage = Install/Update +sitesPrefPage = Available Software Sites +installedSoftwarePage = Installed Software +installHistoryPage = Installation History +preferenceKeywords.general=automatic update schedule download site software install import bundle +preferences=Update and Install Preferences
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/plugin.xml b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/plugin.xml new file mode 100644 index 000000000..4847b0eb0 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/plugin.xml @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + + <extension + id="application" + point="org.eclipse.core.runtime.applications"> + <application> + <run + class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Application"> + </run> + </application> + </extension> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + name="RCP Perspective" + class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Perspective" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.perspective"> + </perspective> + </extension> + <extension + point="org.eclipse.ui.views"> + <view + name="Message" + allowMultiple="true" + icon="icons/sample2.gif" + class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.View" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.view"> + </view> + <view + name="Mailboxes" + allowMultiple="true" + icon="icons/sample3.gif" + class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.NavigationView" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.navigationView"> + </view> + </extension> + <extension + point="org.eclipse.ui.commands"> + <category + name="Mail" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.category"> + </category> + <command + name="Open Mailbox" + description="Opens a mailbox" + categoryId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.category" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.open"> + </command> + <command + name="Open Message Dialog" + description="Open a message dialog" + categoryId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.category" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.openMessage"> + </command> + </extension> + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.open" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+2"> + </key> + <key + commandId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.openMessage" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+3"> + </key> + <key + commandId="org.eclipse.ui.file.exit" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+X"> + </key> + </extension> + <extension + id="product" + point="org.eclipse.core.runtime.products"> + <product + application="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.application" + name="RCP Product"> + <property + name="aboutText" + value="RCP Mail template created by PDE"> + </property> + <property + name="windowImages" + value="icons/sample2.gif"> + </property> + <property + name="aboutImage" + value="product_lg.gif"> + </property> + </product> + </extension> + <extension + point="org.eclipse.ui.installationPages"> + <page + name="%installedSoftwarePage" + class="org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstalledSoftwarePage" + id="10.org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.InstalledSoftwarePage"> + </page> + <page + name="%installHistoryPage" + class="org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RevertProfilePage" + id="11.org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.RevertProfilePage"> + </page> + + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + name="%Update.command" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.command.update"> + </command> + <command + name="%Install.command" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.command.install"> + </command> + </extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + commandId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.command.update" + class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2.UpdateHandler"> + </handler> + <handler + commandId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.command.install" + class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2.InstallNewSoftwareHandler"> + </handler> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + locationURI="menu:tools?after=additions"> + <command + commandId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.command.update" + mnemonic="%Update.command.mnemonic" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.menu.update"> + </command> + + </menuContribution> + <menuContribution + locationURI="menu:tools?after=org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.menu.update"> + <command + commandId="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.command.install" + mnemonic="%Install.command.mnemonic" + id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.menu.install"> + </command> + </menuContribution> + </extension> + + <extension + point="org.eclipse.ui.preferencePages"> + <page + name="%provisioningPrefPage" + class="org.eclipse.equinox.internal.p2.ui.sdk.prefs.ProvisioningPreferencePage" + id="org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage"> + <keywordReference id="org.eclipse.equinox.p2.ui.sdk.updates.general"/> + </page> + + <page + name="%sitesPrefPage" + category="org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage" + class="org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositoryManipulationPage" + id="org.eclipse.equinox.internal.p2.ui.sdk.SitesPreferencePage"> + <keywordReference id="org.eclipse.equinox.p2.ui.sdk.updates.general"/> + </page> + + </extension> + + <extension + point="org.eclipse.ui.keywords"> + <keyword + label="%preferenceKeywords.general" + id="org.eclipse.equinox.p2.ui.sdk.updates.general"/> + </extension> + + <extension + id="preferences" point="org.eclipse.core.runtime.preferences" name="%preferences"> + <initializer class="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.PreferenceInitializer"/> + </extension> +</plugin> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/product_lg.gif b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/product_lg.gif Binary files differnew file mode 100644 index 000000000..bd95e283f --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/product_lg.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/sdkbundlevisibility.product b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/sdkbundlevisibility.product new file mode 100644 index 000000000..436ed2dbd --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/sdkbundlevisibility.product @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="RCP Mail Example (Bundle Visibility Update Example)" id="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.product" application="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.application" version="1.0.0.qualifier" useFeatures="false"> + + <aboutInfo> + <image path="product_lg.gif"/> + <text> + RCP Mail Example (Bundle Visibility Update Example) + </text> + </aboutInfo> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <windowImages i16="icons/sample2.gif"/> + + <splash + location="org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility" /> + <launcher name="sdkbundlevisibility"> + <solaris/> + <win useIco="false"> + <bmp/> + </win> + </launcher> + + <vm> + </vm> + + <plugins> + <plugin id="aaa"/> + <plugin id="com.ibm.icu"/> + <plugin id="org.apache.commons.codec"/> + <plugin id="org.apache.commons.httpclient"/> + <plugin id="org.apache.commons.logging"/> + <plugin id="org.eclipse.core.commands"/> + <plugin id="org.eclipse.core.contenttype"/> + <plugin id="org.eclipse.core.databinding"/> + <plugin id="org.eclipse.core.databinding.observable"/> + <plugin id="org.eclipse.core.databinding.property"/> + <plugin id="org.eclipse.core.expressions"/> + <plugin id="org.eclipse.core.jobs"/> + <plugin id="org.eclipse.core.runtime"/> + <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> + <plugin id="org.eclipse.ecf"/> + <plugin id="org.eclipse.ecf.filetransfer"/> + <plugin id="org.eclipse.ecf.identity"/> + <plugin id="org.eclipse.ecf.provider.filetransfer"/> + <plugin id="org.eclipse.ecf.provider.filetransfer.httpclient"/> + <plugin id="org.eclipse.ecf.provider.filetransfer.httpclient.ssl" fragment="true"/> + <plugin id="org.eclipse.ecf.provider.filetransfer.ssl" fragment="true"/> + <plugin id="org.eclipse.ecf.ssl" fragment="true"/> + <plugin id="org.eclipse.equinox.app"/> + <plugin id="org.eclipse.equinox.common"/> + <plugin id="org.eclipse.equinox.frameworkadmin"/> + <plugin id="org.eclipse.equinox.frameworkadmin.equinox"/> + <plugin id="org.eclipse.equinox.p2.artifact.repository"/> + <plugin id="org.eclipse.equinox.p2.core"/> + <plugin id="org.eclipse.equinox.p2.director"/> + <plugin id="org.eclipse.equinox.p2.directorywatcher"/> + <plugin id="org.eclipse.equinox.p2.engine"/> + <plugin id="org.eclipse.equinox.p2.examples.rcp.cloud"/> + <plugin id="org.eclipse.equinox.p2.exemplarysetup"/> + <plugin id="org.eclipse.equinox.p2.extensionlocation"/> + <plugin id="org.eclipse.equinox.p2.garbagecollector"/> + <plugin id="org.eclipse.equinox.p2.jarprocessor"/> + <plugin id="org.eclipse.equinox.p2.metadata"/> + <plugin id="org.eclipse.equinox.p2.metadata.repository"/> + <plugin id="org.eclipse.equinox.p2.publisher"/> + <plugin id="org.eclipse.equinox.p2.touchpoint.eclipse"/> + <plugin id="org.eclipse.equinox.p2.ui"/> + <plugin id="org.eclipse.equinox.p2.ui.sdk.scheduler"/> + <plugin id="org.eclipse.equinox.p2.updatechecker"/> + <plugin id="org.eclipse.equinox.p2.updatesite"/> + <plugin id="org.eclipse.equinox.preferences"/> + <plugin id="org.eclipse.equinox.registry"/> + <plugin id="org.eclipse.equinox.security"/> + <plugin id="org.eclipse.equinox.security.ui"/> + <plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/> + <plugin id="org.eclipse.equinox.simpleconfigurator"/> + <plugin id="org.eclipse.equinox.simpleconfigurator.manipulator"/> + <plugin id="org.eclipse.help"/> + <plugin id="org.eclipse.jface"/> + <plugin id="org.eclipse.jface.databinding"/> + <plugin id="org.eclipse.osgi"/> + <plugin id="org.eclipse.osgi.services"/> + <plugin id="org.eclipse.swt"/> + <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/> + <plugin id="org.eclipse.ui"/> + <plugin id="org.eclipse.ui.workbench"/> + <plugin id="org.sat4j.core"/> + <plugin id="org.sat4j.pb"/> + </plugins> + + +</product> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/splash.bmp b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/splash.bmp Binary files differnew file mode 100644 index 000000000..d7d2e3032 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/splash.bmp diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Activator.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Activator.java new file mode 100644 index 000000000..b1325f9c2 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Activator.java @@ -0,0 +1,87 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.equinox.internal.provisional.p2.ui.ProfileFactory; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.ColocatedRepositoryManipulator; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.IProfileChooser; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; +import org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2.PreferenceConstants; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.widgets.Shell; +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 = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility"; + + // 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); + initializeP2Policies(); + plugin = this; + } + + private void initializeP2Policies() { + Policy policy = Policy.getDefault(); + // XXX Where a profile must be chosen, use the running profile + policy.setProfileChooser(new IProfileChooser() { + public String getProfileId(Shell shell) { + return ProfileFactory.makeProfile("Canned").getProfileId(); + } + }); + // XXX Use the pref-based repository manipulator + policy.setRepositoryManipulator(new ColocatedRepositoryManipulator(policy, PreferenceConstants.PREF_PAGE_SITES)); + + // XXX Change the visibility of the IUs shown in the UI + IUViewQueryContext context = policy.getQueryContext(); + context.setVisibleAvailableIUProperty(null); + context.setVisibleInstalledIUProperty(null); + + } + + /* + * (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); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Application.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Application.java new file mode 100644 index 000000000..2fb79727e --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Application.java @@ -0,0 +1,45 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + +/** + * This class controls all aspects of the application's execution + */ +public class Application implements IApplication { + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) { + Display display = PlatformUI.createDisplay(); + try { + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + final IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench == null) + return; + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationActionBarAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationActionBarAdvisor.java new file mode 100644 index 000000000..86b3594f2 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationActionBarAdvisor.java @@ -0,0 +1,107 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.ICoolBarManager; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.action.ToolBarContributionItem; +import org.eclipse.jface.action.ToolBarManager; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; + +/** + * An action bar advisor is responsible for creating, adding, and disposing of the + * actions added to a workbench window. Each window will be populated with + * new actions. + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + + // Actions - important to allocate these only in makeActions, and then use them + // in the fill methods. This ensures that the actions aren't recreated + // when fillActionBars is called with FILL_PROXY. + private IWorkbenchAction exitAction; + private IWorkbenchAction aboutAction; + private IWorkbenchAction newWindowAction; + // XXX we want to show preferences + private IWorkbenchAction preferencesAction; + private OpenViewAction openViewAction; + private Action messagePopupAction; + + public static final String M_TOOLS = "tools"; + + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(final IWorkbenchWindow window) { + // Creates the actions and registers them. + // Registering is needed to ensure that key bindings work. + // The corresponding commands keybindings are defined in the plugin.xml file. + // Registering also provides automatic disposal of the actions when + // the window is closed. + + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + + aboutAction = ActionFactory.ABOUT.create(window); + register(aboutAction); + + // XXX we want to show auto update preferences + preferencesAction = ActionFactory.PREFERENCES.create(window); + register(preferencesAction); + + newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window); + register(newWindowAction); + + openViewAction = new OpenViewAction(window, "Open Another Message View", View.ID); + register(openViewAction); + + messagePopupAction = new MessagePopupAction("Open Message", window); + register(messagePopupAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + // XXX add a tools menu + MenuManager toolsMenu = new MenuManager("&Tools", M_TOOLS); + MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); + + menuBar.add(fileMenu); + menuBar.add(toolsMenu); + // Add a group marker indicating where action set menus will appear. + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(helpMenu); + + // File + fileMenu.add(newWindowAction); + fileMenu.add(new Separator()); + fileMenu.add(messagePopupAction); + fileMenu.add(openViewAction); + fileMenu.add(new Separator()); + fileMenu.add(exitAction); + + // XXX add preferences to tools + toolsMenu.add(preferencesAction); + toolsMenu.add(new Separator()); + toolsMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + + // Help + helpMenu.add(aboutAction); + } + + protected void fillCoolBar(ICoolBarManager coolBar) { + IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT); + coolBar.add(new ToolBarContributionItem(toolbar, "main")); + toolbar.add(openViewAction); + toolbar.add(messagePopupAction); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationWorkbenchAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationWorkbenchAdvisor.java new file mode 100644 index 000000000..ce56de956 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,21 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +/** + * This workbench advisor creates the window advisor, and specifies + * the perspective id for the initial window. + */ +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return Perspective.ID; + } + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationWorkbenchWindowAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 000000000..2f512930a --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,30 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(600, 400)); + configurer.setShowCoolBar(true); + // XXX Set the status line and progress indicator so that update + // information can be shown there + configurer.setShowStatusLine(true); + configurer.setShowProgressIndicator(true); + + } + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ICommandIds.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ICommandIds.java new file mode 100644 index 000000000..96e8172ef --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/ICommandIds.java @@ -0,0 +1,15 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +/** + * Interface defining the application's command IDs. + * Key bindings can be defined for specific commands. + * To associate an action with a command, use IAction.setActionDefinitionId(commandId). + * + * @see org.eclipse.jface.action.IAction#setActionDefinitionId(String) + */ +public interface ICommandIds { + + public static final String CMD_OPEN = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.open"; + public static final String CMD_OPEN_MESSAGE = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.openMessage"; + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/MessagePopupAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/MessagePopupAction.java new file mode 100644 index 000000000..a9a83e99c --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/MessagePopupAction.java @@ -0,0 +1,25 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchWindow; + + +public class MessagePopupAction extends Action { + + private final IWorkbenchWindow window; + + MessagePopupAction(String text, IWorkbenchWindow window) { + super(text); + this.window = window; + // The id is used to refer to the action in a menu or toolbar + setId(ICommandIds.CMD_OPEN_MESSAGE); + // Associate the action with a pre-defined command, to allow key bindings. + setActionDefinitionId(ICommandIds.CMD_OPEN_MESSAGE); + setImageDescriptor(org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Activator.getImageDescriptor("/icons/sample3.gif")); + } + + public void run() { + MessageDialog.openInformation(window.getShell(), "Open", "Open Message Dialog!"); + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/NavigationView.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/NavigationView.java new file mode 100644 index 000000000..87949a3bc --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/NavigationView.java @@ -0,0 +1,151 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import java.util.ArrayList; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + +public class NavigationView extends ViewPart { + public static final String ID = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.navigationView"; + private TreeViewer viewer; + + class TreeObject { + private String name; + private TreeParent parent; + + public TreeObject(String name) { + this.name = name; + } + public String getName() { + return name; + } + public void setParent(TreeParent parent) { + this.parent = parent; + } + public TreeParent getParent() { + return parent; + } + public String toString() { + return getName(); + } + } + + class TreeParent extends TreeObject { + private ArrayList children; + public TreeParent(String name) { + super(name); + children = new ArrayList(); + } + public void addChild(TreeObject child) { + children.add(child); + child.setParent(this); + } + public void removeChild(TreeObject child) { + children.remove(child); + child.setParent(null); + } + public TreeObject[] getChildren() { + return (TreeObject[]) children.toArray(new TreeObject[children.size()]); + } + public boolean hasChildren() { + return children.size()>0; + } + } + + class ViewContentProvider implements IStructuredContentProvider, + ITreeContentProvider { + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + return getChildren(parent); + } + + public Object getParent(Object child) { + if (child instanceof TreeObject) { + return ((TreeObject)child).getParent(); + } + return null; + } + + public Object[] getChildren(Object parent) { + if (parent instanceof TreeParent) { + return ((TreeParent)parent).getChildren(); + } + return new Object[0]; + } + + public boolean hasChildren(Object parent) { + if (parent instanceof TreeParent) + return ((TreeParent)parent).hasChildren(); + return false; + } + } + + class ViewLabelProvider extends LabelProvider { + + public String getText(Object obj) { + return obj.toString(); + } + public Image getImage(Object obj) { + String imageKey = ISharedImages.IMG_OBJ_ELEMENT; + if (obj instanceof TreeParent) + imageKey = ISharedImages.IMG_OBJ_FOLDER; + return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey); + } + } + + /** + * We will set up a dummy model to initialize tree heararchy. In real + * code, you will connect to a real model and expose its hierarchy. + */ + private TreeObject createDummyModel() { + TreeObject to1 = new TreeObject("Inbox"); + TreeObject to2 = new TreeObject("Drafts"); + TreeObject to3 = new TreeObject("Sent"); + TreeParent p1 = new TreeParent("me@this.com"); + p1.addChild(to1); + p1.addChild(to2); + p1.addChild(to3); + + TreeObject to4 = new TreeObject("Inbox"); + TreeParent p2 = new TreeParent("other@aol.com"); + p2.addChild(to4); + + TreeParent root = new TreeParent(""); + root.addChild(p1); + root.addChild(p2); + return root; + } + + /** + * This is a callback that will allow us to create the viewer and initialize + * it. + */ + public void createPartControl(Composite parent) { + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + viewer.setContentProvider(new ViewContentProvider()); + viewer.setLabelProvider(new ViewLabelProvider()); + viewer.setInput(createDummyModel()); + } + + /** + * Passing the focus request to the viewer's control. + */ + public void setFocus() { + viewer.getControl().setFocus(); + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/OpenViewAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/OpenViewAction.java new file mode 100644 index 000000000..162da81c3 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/OpenViewAction.java @@ -0,0 +1,36 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; + + +public class OpenViewAction extends Action { + + private final IWorkbenchWindow window; + private int instanceNum = 0; + private final String viewId; + + public OpenViewAction(IWorkbenchWindow window, String label, String viewId) { + this.window = window; + this.viewId = viewId; + setText(label); + // The id is used to refer to the action in a menu or toolbar + setId(ICommandIds.CMD_OPEN); + // Associate the action with a pre-defined command, to allow key bindings. + setActionDefinitionId(ICommandIds.CMD_OPEN); + setImageDescriptor(org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Activator.getImageDescriptor("/icons/sample2.gif")); + } + + public void run() { + if(window != null) { + try { + window.getActivePage().showView(viewId, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE); + } catch (PartInitException e) { + MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage()); + } + } + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Perspective.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Perspective.java new file mode 100644 index 000000000..08aefe17e --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/Perspective.java @@ -0,0 +1,25 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class Perspective implements IPerspectiveFactory { + + /** + * The ID of the perspective as specified in the extension. + */ + public static final String ID = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.perspective"; + + public void createInitialLayout(IPageLayout layout) { + String editorArea = layout.getEditorArea(); + layout.setEditorAreaVisible(false); + + layout.addStandaloneView(NavigationView.ID, false, IPageLayout.LEFT, 0.25f, editorArea); + IFolderLayout folder = layout.createFolder("messages", IPageLayout.TOP, 0.5f, editorArea); + folder.addPlaceholder(View.ID + ":*"); + folder.addView(View.ID); + + layout.getViewLayout(NavigationView.ID).setCloseable(false); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/View.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/View.java new file mode 100644 index 000000000..66f6584f9 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/View.java @@ -0,0 +1,77 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.part.ViewPart; + +public class View extends ViewPart { + + public static final String ID = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.view"; + + public void createPartControl(Composite parent) { + Composite top = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + top.setLayout(layout); + // top banner + Composite banner = new Composite(top, SWT.NONE); + banner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false)); + layout = new GridLayout(); + layout.marginHeight = 5; + layout.marginWidth = 10; + layout.numColumns = 2; + banner.setLayout(layout); + + // setup bold font + Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); + + Label l = new Label(banner, SWT.WRAP); + l.setText("Subject:"); + l.setFont(boldFont); + l = new Label(banner, SWT.WRAP); + l.setText("This is a message about the cool Eclipse RCP!"); + + l = new Label(banner, SWT.WRAP); + l.setText("From:"); + l.setFont(boldFont); + + final Link link = new Link(banner, SWT.NONE); + link.setText("<a>nicole@mail.org</a>"); + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + MessageDialog.openInformation(getSite().getShell(), "Not Implemented", "Imagine the address book or a new message being created now."); + } + }); + + l = new Label(banner, SWT.WRAP); + l.setText("Date:"); + l.setFont(boldFont); + l = new Label(banner, SWT.WRAP); + l.setText("10:34 am"); + // message contents + Text text = new Text(top, SWT.MULTI | SWT.WRAP); + text.setText("This RCP Application was generated from the PDE Plug-in Project wizard. This sample shows how to:\n"+ + "- add a top-level menu and toolbar with actions\n"+ + "- add keybindings to actions\n" + + "- create views that can't be closed and\n"+ + " multiple instances of the same view\n"+ + "- perspectives with placeholders for new views\n"+ + "- use the default about dialog\n"+ + "- create a product definition\n"); + text.setLayoutData(new GridData(GridData.FILL_BOTH)); + } + + public void setFocus() { + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/IProvSDKHelpContextIds.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/IProvSDKHelpContextIds.java new file mode 100644 index 000000000..eccbe3555 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/IProvSDKHelpContextIds.java @@ -0,0 +1,17 @@ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +/** + * Help context ids for the P2 SDK + * <p> + * This interface contains constants only; it is not intended to be implemented + * or extended. + * </p> + * @since 3.4 + */ + +public interface IProvSDKHelpContextIds { + // XXX Must match the id used in the help doc + public static final String PREFIX = "org.eclipse.equinox.p2.ui.sdk"; //$NON-NLS-1$ + + public static final String PROVISIONING_PREFERENCE_PAGE = PREFIX + "provisioning_preference_page_context"; //$NON-NLS-1$ +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java new file mode 100644 index 000000000..a1d45b582 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/InstallNewSoftwareHandler.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +import org.eclipse.equinox.internal.provisional.p2.ui.IProvHelpContextIds; +import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstallWizard; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.PlatformUI; + +/** + * InstallNewSoftwareHandler invokes the install wizard + * + * @since 3.5 + */ +public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler { + + /** + * The constructor. + */ + public InstallNewSoftwareHandler() { + super(); + } + + protected void doExecute(String profileId, QueryableMetadataRepositoryManager manager) { + InstallWizard wizard = new InstallWizard(Policy.getDefault(), profileId, null, null, manager); + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.create(); + PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IProvHelpContextIds.INSTALL_WIZARD); + + dialog.open(); + } + + protected boolean waitForPreload() { + // If there is no way for the user to manipulate repositories, + // then we may as well wait for existing repos to load so that + // content is available. If the user can manipulate the + // repositories, then we don't wait, because we don't know which + // ones they want to work with. + return Policy.getDefault().getRepositoryManipulator() == null; + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java new file mode 100644 index 000000000..8713ba269 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/Messages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2.messages"; //$NON-NLS-1$ + static { + // load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + public static String InstallNewSoftwareHandler_LoadRepositoryJobLabel; + public static String UpdateHandler_NoSitesMessage; + public static String UpdateHandler_NoSitesTitle; + public static String ProvisioningPreferencePage_AlwaysOpenWizard; + public static String ProvisioningPreferencePage_BrowsingPrefsGroup; + public static String ProvisioningPreferencePage_ShowLatestVersions; + public static String ProvisioningPreferencePage_ShowAllVersions; + public static String ProvisioningPreferencePage_NeverOpenWizard; + public static String ProvisioningPreferencePage_OpenWizardIfInvalid; + public static String ProvisioningPreferencePage_PromptToOpenWizard; + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreferenceConstants.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreferenceConstants.java new file mode 100644 index 000000000..ea29eb88a --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreferenceConstants.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +/** + * @since 3.4 + */ +public class PreferenceConstants { + public static final String PREF_PAGE_PROVISIONING = "org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage"; //$NON-NLS-1$ + public static final String PREF_PAGE_SITES = "org.eclipse.equinox.internal.p2.ui.sdk.SitesPreferencePage"; //$NON-NLS-1$ + public static final String PREF_SHOW_LATEST_VERSION = "showLatestVersion"; //$NON-NLS-1$ + public static final String PREF_OPEN_WIZARD_ON_ERROR_PLAN = "allowNonOKPlan"; //$NON-NLS-1$ +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreferenceInitializer.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreferenceInitializer.java new file mode 100644 index 000000000..858b04fd6 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreferenceInitializer.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.jface.dialogs.MessageDialogWithToggle; +import org.osgi.service.prefs.Preferences; + +/** + * @since 3.4 + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + Preferences node = new DefaultScope().getNode("org.eclipse.equinox.p2.ui.sdk"); //$NON-NLS-1$ + node.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, true); + node.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT); + } + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java new file mode 100644 index 000000000..dec8d9bd7 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/PreloadingRepositoryHandler.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.jobs.*; +import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; +import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI; +import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; + +/** + * PreloadingRepositoryHandler provides background loading of repositories + * before executing the provisioning handler. + * + * @since 3.5 + */ +abstract class PreloadingRepositoryHandler extends AbstractHandler { + + Object LOAD_FAMILY = new Object(); + + /** + * The constructor. + */ + public PreloadingRepositoryHandler() { + // constructor + } + + /** + * Execute the command. + */ + public Object execute(ExecutionEvent event) { + final String profileId = IProfileRegistry.SELF; + BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { + public void run() { + doExecuteAndLoad(profileId, preloadRepositories()); + } + }); + return null; + } + + void doExecuteAndLoad(final String profileId, boolean preloadRepositories) { + // cancel any load that is already running + Job.getJobManager().cancel(LOAD_FAMILY); + final QueryableMetadataRepositoryManager queryableManager = new QueryableMetadataRepositoryManager( + Policy.getDefault().getQueryContext(), false); + if (preloadRepositories) { + Job loadJob = new Job( + Messages.InstallNewSoftwareHandler_LoadRepositoryJobLabel) { + + protected IStatus run(IProgressMonitor monitor) { + queryableManager.loadAll(monitor); + return Status.OK_STATUS; + } + + public boolean belongsTo(Object family) { + return family == LOAD_FAMILY; + } + + }; + if (waitForPreload()) { + loadJob.addJobChangeListener(new JobChangeAdapter() { + public void done(IJobChangeEvent event) { + if (PlatformUI.isWorkbenchRunning()) + if (event.getResult().isOK()) { + PlatformUI.getWorkbench().getDisplay() + .asyncExec(new Runnable() { + public void run() { + doExecute(profileId, + queryableManager); + } + }); + } + } + }); + loadJob.setUser(true); + loadJob.schedule(); + + } else { + loadJob.setSystem(true); + loadJob.setUser(false); + loadJob.schedule(); + doExecute(profileId, queryableManager); + } + } else { + doExecute(profileId, queryableManager); + } + } + + protected abstract void doExecute(String profileId, + QueryableMetadataRepositoryManager manager); + + protected boolean preloadRepositories() { + return true; + } + + protected boolean waitForPreload() { + return true; + } + + /** + * Return a shell appropriate for parenting dialogs of this handler. + * + * @return a Shell + */ + protected Shell getShell() { + return ProvUI.getDefaultParentShell(); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java new file mode 100644 index 000000000..9a049f939 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/ProvisioningPreferencePage.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +import org.eclipse.core.runtime.Preferences; +import org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.Activator; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.MessageDialogWithToggle; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.*; +import org.eclipse.ui.*; + +/** + * Preference page for general provisioning preferences. + * + * @since 3.4 + */ + +public class ProvisioningPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + private Group browsingGroup, validateGroup; + private Button showLatestRadio, showAllRadio; + private Button alwaysShowFailedPlan, neverShowFailedPlan, promptOnFailedPlan; + + protected Control createContents(Composite parent) { + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IProvSDKHelpContextIds.PROVISIONING_PREFERENCE_PAGE); + + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + layout.marginWidth = layout.marginHeight = 0; + container.setLayout(layout); + + // Group for show all versions vs. show latest + browsingGroup = new Group(container, SWT.NONE); + browsingGroup.setText(Messages.ProvisioningPreferencePage_BrowsingPrefsGroup); + layout = new GridLayout(); + layout.numColumns = 3; + browsingGroup.setLayout(layout); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + browsingGroup.setLayoutData(gd); + + showLatestRadio = new Button(browsingGroup, SWT.RADIO); + showLatestRadio.setText(Messages.ProvisioningPreferencePage_ShowLatestVersions); + gd = new GridData(); + gd.horizontalSpan = 3; + showLatestRadio.setLayoutData(gd); + + showAllRadio = new Button(browsingGroup, SWT.RADIO); + showAllRadio.setText(Messages.ProvisioningPreferencePage_ShowAllVersions); + gd = new GridData(); + gd.horizontalSpan = 3; + showAllRadio.setLayoutData(gd); + + //Group for validating a failed plan + validateGroup = new Group(container, SWT.NONE); + validateGroup.setText(Messages.ProvisioningPreferencePage_OpenWizardIfInvalid); + layout = new GridLayout(); + layout.numColumns = 3; + validateGroup.setLayout(layout); + gd = new GridData(GridData.FILL_HORIZONTAL); + validateGroup.setLayoutData(gd); + + alwaysShowFailedPlan = new Button(validateGroup, SWT.RADIO); + alwaysShowFailedPlan.setText(Messages.ProvisioningPreferencePage_AlwaysOpenWizard); + gd = new GridData(); + gd.horizontalSpan = 3; + alwaysShowFailedPlan.setLayoutData(gd); + + neverShowFailedPlan = new Button(validateGroup, SWT.RADIO); + neverShowFailedPlan.setText(Messages.ProvisioningPreferencePage_NeverOpenWizard); + gd = new GridData(); + gd.horizontalSpan = 3; + neverShowFailedPlan.setLayoutData(gd); + + promptOnFailedPlan = new Button(validateGroup, SWT.RADIO); + promptOnFailedPlan.setText(Messages.ProvisioningPreferencePage_PromptToOpenWizard); + gd = new GridData(); + gd.horizontalSpan = 3; + promptOnFailedPlan.setLayoutData(gd); + + initialize(); + + Dialog.applyDialogFont(container); + return container; + + } + + private void initialize() { + Preferences pref = Activator.getDefault().getPluginPreferences(); + showLatestRadio.setSelection(pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION)); + showAllRadio.setSelection(!pref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION)); + String openWizard = pref.getString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN); + alwaysShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.ALWAYS)); + neverShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.NEVER)); + promptOnFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.PROMPT)); + } + + protected void performDefaults() { + super.performDefaults(); + Preferences pref = Activator.getDefault().getPluginPreferences(); + showLatestRadio.setSelection(pref.getDefaultBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION)); + showAllRadio.setSelection(!pref.getDefaultBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION)); + String openWizard = pref.getDefaultString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN); + alwaysShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.ALWAYS)); + neverShowFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.NEVER)); + promptOnFailedPlan.setSelection(openWizard.equals(MessageDialogWithToggle.PROMPT)); + } + + public boolean performOk() { + Preferences pref = Activator.getDefault().getPluginPreferences(); + pref.setValue(PreferenceConstants.PREF_SHOW_LATEST_VERSION, showLatestRadio.getSelection()); + if (alwaysShowFailedPlan.getSelection()) + pref.setValue(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.ALWAYS); + else if (neverShowFailedPlan.getSelection()) + pref.setValue(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.NEVER); + else + pref.setValue(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT); + + Activator.getDefault().savePluginPreferences(); + return true; + } + + public void init(IWorkbench workbench) { + // Nothing to do + } + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java new file mode 100644 index 000000000..891be7e10 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/UpdateHandler.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility.p2; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.ui.ElementQueryDescriptor; +import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI; +import org.eclipse.equinox.internal.provisional.p2.ui.QueryableMetadataRepositoryManager; +import org.eclipse.equinox.internal.provisional.p2.ui.actions.UpdateAction; +import org.eclipse.equinox.internal.provisional.p2.ui.model.ProfileElement; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy; +import org.eclipse.equinox.internal.provisional.p2.ui.policy.RepositoryManipulator; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.StructuredSelection; + +/** + * UpdateHandler invokes the check for updates UI + * + * @since 3.4 + */ +public class UpdateHandler extends PreloadingRepositoryHandler { + + boolean hasNoRepos = false; + + /** + * The constructor. + */ + public UpdateHandler() { + // constructor + } + + protected void doExecute(String profileId, QueryableMetadataRepositoryManager manager) { + if (hasNoRepos) { + boolean goToSites = MessageDialog.openQuestion(getShell(), Messages.UpdateHandler_NoSitesTitle, Messages.UpdateHandler_NoSitesMessage); + if (goToSites) { + Policy.getDefault().getRepositoryManipulator().manipulateRepositories(getShell()); + } + return; + } + // get the profile roots + ElementQueryDescriptor queryDescriptor = Policy.getDefault().getQueryProvider().getQueryDescriptor(new ProfileElement(null, profileId)); + Collection collection = queryDescriptor.performQuery(null); + final IInstallableUnit[] roots = new IInstallableUnit[collection.size()]; + Iterator iter = collection.iterator(); + int i = 0; + while (iter.hasNext()) { + roots[i] = (IInstallableUnit) ProvUI.getAdapter(iter.next(), IInstallableUnit.class); + i++; + } + // now create an update action whose selection is all the roots + UpdateAction action = new UpdateAction(Policy.getDefault(), new ISelectionProvider() { + + public void addSelectionChangedListener(ISelectionChangedListener listener) { + // not dynamic + } + + public ISelection getSelection() { + return new StructuredSelection(roots); + } + + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + // not dynamic + } + + public void setSelection(ISelection selection) { + // not mutable + + } + }, profileId, false); + action.setRepositoryManager(manager); + action.run(); + } + + protected boolean preloadRepositories() { + hasNoRepos = false; + RepositoryManipulator repoMan = Policy.getDefault().getRepositoryManipulator(); + if (repoMan != null && repoMan.getKnownRepositories().length == 0) { + hasNoRepos = true; + return false; + } + return super.preloadRepositories(); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties new file mode 100644 index 000000000..21475c188 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility/src/org/eclipse/equinox/p2/examples/rcp/sdkbundlevisibility/p2/messages.properties @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2009 IBM Corporation and others. +# 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: +# IBM Corporation - initial API and implementation +############################################################################### + + +InstallNewSoftwareHandler_LoadRepositoryJobLabel=Contacting Software Sites +UpdateHandler_NoSitesMessage=There are no update sites to search. Do you wish to open the "Available Software Sites" preferences? +UpdateHandler_NoSitesTitle=No Updates Found +ProvisioningPreferencePage_AlwaysOpenWizard=&Open the wizard anyway to review or change selections +ProvisioningPreferencePage_BrowsingPrefsGroup=Browsing for updates +ProvisioningPreferencePage_ShowLatestVersions=Show only the &latest versions of available software +ProvisioningPreferencePage_ShowAllVersions=Show all &versions of available software +ProvisioningPreferencePage_NeverOpenWizard=&Report the problems and do not open the wizard +ProvisioningPreferencePage_OpenWizardIfInvalid=When software selected for an install wizard may not be compatible +ProvisioningPreferencePage_PromptToOpenWizard=&Ask me what to do when it happens |