diff options
author | spingel | 2010-04-25 04:44:35 +0000 |
---|---|---|
committer | spingel | 2010-04-25 04:44:35 +0000 |
commit | a62b8efd70ebf7fc7d23729ccb1d3e2be8246a65 (patch) | |
tree | 5873768d127e5ade123b17d6c1c0223348cb5443 /examples | |
parent | 5bdc08e098e9b466572be4d7b738df14d22acd57 (diff) | |
download | rt.equinox.p2-a62b8efd70ebf7fc7d23729ccb1d3e2be8246a65.tar.gz rt.equinox.p2-a62b8efd70ebf7fc7d23729ccb1d3e2be8246a65.tar.xz rt.equinox.p2-a62b8efd70ebf7fc7d23729ccb1d3e2be8246a65.zip |
bug 309874 - [discovery] provide RCP example for discovery based extension install
Diffstat (limited to 'examples')
43 files changed, 1511 insertions, 0 deletions
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/.cvsignore b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/.cvsignore new file mode 100644 index 000000000..23c798ce4 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/.cvsignore @@ -0,0 +1,2 @@ +repository +buildDirectory diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/.project b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/.project new file mode 100644 index 000000000..80d1497a6 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/.project @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.p2.examples.rcp.discovery.releng</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + </buildSpec> + <natures> + </natures> +</projectDescription> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/Build Discovery Example.launch b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/Build Discovery Example.launch new file mode 100644 index 000000000..8442bedd4 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/Build Discovery Example.launch @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.ant.AntLaunchConfigurationType"> +<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.equinox.p2.examples.rcp.discovery.releng/buildProduct.xml"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/build.log"/> +<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.examples.rcp.discovery.releng"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.equinox.p2.examples.rcp.discovery.releng/buildProduct.xml}"/> +<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/> +</launchConfiguration> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/build.properties b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/build.properties new file mode 100644 index 000000000..4be192c46 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/build.properties @@ -0,0 +1,120 @@ +############################################################################### +# Copyright (c) 2003, 2006 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 +############################################################################### +product=/org.eclipse.equinox.p2.examples.rcp.cloud/cloud.product +runPackager=true + +p2.gathering=true +p2.metadata.repo=file:${builder}/repository +p2.artifact.repo=file:${builder}/repository + +#Set the name of the archive that will result from the product build. +#archiveNamePrefix= + +# The prefix that will be used in the generated archive. +archivePrefix=eclipse + +# The location underwhich all of the build output will be collected. +collectingFolder=${archivePrefix} + +# The list of {os, ws, arch} configurations to build. This +# value is a '&' separated list of ',' separate triples. For example, +# configs=win32,win32,x86 & linux,motif,x86 +# By default the value is *,*,* +configs = win32, win32, x86 & \ + linux, gtk, x86 +#configs=win32, win32, x86 & \ +# linux, gtk, ppc &\ +# linux, gtk, x86 & \ +# linux, gtk, x86_64 & \ +# linux, motif, x86 & \ +# solaris, motif, sparc & \ +# solaris, gtk, sparc & \ +# aix, motif, ppc & \ +# hpux, motif, PA_RISC & \ +# macosx, carbon, ppc + +#Allow cycles involving at most one bundle that needs to be compiled with the rest being binary bundles. +allowBinaryCycles = true + +# Type of build. Used in naming the build output. Typically this value is +# one of I, N, M, S, ... +buildType=I + +# ID of the build. Used in naming the build output. +buildId=TestBuild + +# Label for the build. Used in naming the build output +buildLabel=${buildType}.${buildId} + +# Timestamp for the build. Used in naming the build output +timestamp=007 + +#this property indicates whether the resolution should be done in development mode (i.e. ignore multiple bundles with singletons) +resolution.devMode=false + +skipBase=true +skipMaps=true +skipFetch=true + + +############# JAVA COMPILER OPTIONS ############## +# For this example: +# We specify the JRE locations for CDC-1.1/Foundation-1.1 and J2SE-1.5 +# because these are the required execution environments defined for the +# bundles in the example. + +# The location of the Java jars to compile against. Typically the rt.jar for your JDK/JRE +#bootclasspath=${java.home}/lib/rt.jar + +# If using an IBM VM, use +#bootclasspath=${java.home}/lib/core.jar;${java.home}/lib/vm.jar + +# specific JRE locations to compile against. These values are used to compile bundles specifying a +# Bundle-RequiredExecutionEnvironment. Uncomment and set values for environments that you support +#CDC-1.0/Foundation-1.0= /path/to/rt.jar +CDC-1.1/Foundation-1.1=${java.home}/lib/rt.jar +#OSGi/Minimum-1.0= +#OSGi/Minimum-1.1= +#JRE-1.1= +#J2SE-1.2= +#J2SE-1.3= +#J2SE-1.4= +J2SE-1.5=${java.home}/lib/rt.jar +#JavaSE-1.6= +#PersonalJava-1.1= +#PersonalJava-1.2= +#CDC-1.0/PersonalBasis-1.0= +#CDC-1.0/PersonalJava-1.0= +#CDC-1.1/PersonalBasis-1.1= +#CDC-1.1/PersonalJava-1.1= + +# Specify the output format of the compiler log when eclipse jdt is used +logExtension=.log + +# Whether or not to include debug info in the output jars +javacDebugInfo=false + +# Whether or not to fail the build if there are compiler errors +javacFailOnError=true + +# Enable or disable verbose mode of the compiler +javacVerbose=true + +# Extra arguments for the compiler. These are specific to the java compiler being used. +#compilerArg= + +# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties +#javacSource=1.3 + +# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties. +#javacTarget=1.1 + + diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/buildProduct.xml b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/buildProduct.xml new file mode 100644 index 000000000..e8019d41a --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/buildProduct.xml @@ -0,0 +1,49 @@ +<project default="main"> + <target name="main"> + <property name="baseLocation" value="${eclipse.home}"/> + <!-- by default, check for deltapack co-located with eclipse --> + <property name="deltapack" value="${eclipse.home}/../deltapack/eclipse"/> + + <!-- Check that we have a deltapack --> + <available property="haveDeltaPack" file="${deltapack}"/> + <fail unless="haveDeltaPack" message="The deltapack is required to build this product. Please edit buildProduct.xml or set the "deltapack" property." /> + + <property name="builder" value="${basedir}" /> + <property name="buildDirectory" value="${basedir}/buildDirectory"/> + <property name="pluginPath" value="${deltapack}" /> + <property name="buildTempFolder" value="${buildDirectory}" /> + + <!-- Clean build directory and workspace --> + <delete includeemptydirs="true" failonerror="false"> + <fileset dir="${basedir}/buildDirectory"/> + <fileset dir="${basedir}/repository"/> + </delete> + + <!-- Copy plug-ins from workspace --> + <copy todir="${buildDirectory}/plugins"> + <fileset dir="${basedir}/.."> + <include name="org.eclipse.equinox.p2.examples.rcp.discovery/**/*"/> + <exclude name="**/bin/**"/> + </fileset> + </copy> + + <!-- Fix project name of example plugin --> + <move file="${buildDirectory}/plugins/org.eclipse.equinox.p2.examples.rcp.discovery" tofile="${buildDirectory}/plugins/org.eclipse.equinox.p2.examples.rcp.cloud"/> + + <ant antfile="${eclipse.pdebuild.scripts}/productBuild/productBuild.xml" /> + + <move todir="${basedir}"> + <fileset dir="${buildDirectory}/I.TestBuild" includes="*.zip"/> + </move> + + <replace file="${basedir}/repository/content.xml"> + <replacetoken><![CDATA[<update id='org.eclipse.equinox.p2.examples.rcp.cloud.product' range='0.0.0' severity='0'/>]]></replacetoken> + <replacevalue><![CDATA[<update id='org.eclipse.equinox.p2.examples.rcp.cloud.product' range='0.0.0' severity='0' description='This update contains Mylyn Discovery!' uri='http://localhost/updatenotification.png'/>]]></replacevalue> + </replace> + + <!-- refresh the workspace --> + <eclipse.convertPath fileSystemPath="${basedir}" property="resourcePath"/> + <eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/> + </target> + +</project>
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/readme.txt b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/readme.txt new file mode 100644 index 000000000..eb0d08981 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery.releng/readme.txt @@ -0,0 +1,16 @@ +This project is a releng builder for the org.eclipse.equinox.p2.examples.rcp.cloud project. + +1) This build requires 3.5M6 or later + +2) This build requires the deltapack. By default it looks beside the eclipse install for "deltapack/eclipse/*". + If your deltapack is located elsewhere, set the "deltapack" property or edit the buildProduct.xml file. The + version of the deltapack used should match the version of the eclipse that is running. + +3) Due to bug 268867, if the buildDirectory/buildRepo is deleted/cleaned, then the repo must also be removed from + the workspace Available Software Sites preferences. + +4) Use the included launch config, or run buildProduct.xml as an ant build using the same JRE as the workspace + +5) The build.properties file specifically defines the JRE's for CDC-1.1/Foundation-1.1 and + J2SE-1.5 because these are the required bundle execution environments in the example. + The build should be run on a 1.5 VM.
\ No newline at end of file diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.classpath b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.classpath new file mode 100644 index 000000000..3450ccb12 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.classpath @@ -0,0 +1,11 @@ +<?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"> + <accessrules> + <accessrule kind="accessible" pattern="**/internal/**/discovery/**"/> + </accessrules> + </classpathentry> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.project b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.project new file mode 100644 index 000000000..e736f7ff4 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.p2.examples.rcp.discovery</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.discovery/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..8f8669add --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Mar 12 11:04:59 PDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14 +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.discovery/META-INF/MANIFEST.MF b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/META-INF/MANIFEST.MF new file mode 100644 index 000000000..790cb0f49 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/META-INF/MANIFEST.MF @@ -0,0 +1,33 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: RCP Mail (Cloud Update Example) +Bundle-SymbolicName: org.eclipse.equinox.p2.examples.rcp.cloud;singleton:=true +Bundle-Version: 2.0.0.qualifier +Bundle-Activator: org.eclipse.equinox.p2.examples.rcp.cloud.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui;bundle-version="3.6.0", + org.eclipse.core.runtime, + org.eclipse.equinox.p2.operations;bundle-version="2.0.0", + org.eclipse.equinox.p2.ui;bundle-version="2.0.0", + org.eclipse.equinox.p2.metadata;bundle-version="[2.0.0,3.0.0)", + org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0", + org.eclipse.equinox.p2.artifact.repository;bundle-version="1.1.0", + org.eclipse.equinox.p2.extensionlocation;bundle-version="1.0.100", + org.eclipse.equinox.p2.updatesite;bundle-version="1.0.0", + org.eclipse.equinox.p2.director;bundle-version="2.0.0", + org.eclipse.equinox.p2.engine;bundle-version="2.0.0", + org.eclipse.equinox.p2.core;bundle-version="2.0.0", + 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.2.0", + org.apache.commons.httpclient;bundle-version="3.0.1", + org.eclipse.equinox.p2.ui.sdk.scheduler;bundle-version="1.0.0", + org.eclipse.equinox.ds;bundle-version="1.2.0", + org.eclipse.equinox.p2.discovery;bundle-version="1.0.0", + org.eclipse.equinox.p2.discovery.compatibility;bundle-version="1.0.0", + org.eclipse.equinox.p2.ui.discovery;bundle-version="1.0.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/build.properties b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/build.properties new file mode 100644 index 000000000..5c50a0005 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/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.discovery/cloud.product b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/cloud.product new file mode 100644 index 000000000..5a2b36e5e --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/cloud.product @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="RCP Mail Example (p2 Discovery)" id="org.eclipse.equinox.p2.examples.rcp.cloud.product" application="org.eclipse.equinox.p2.examples.rcp.cloud.application" version="2.0.0.qualifier" useFeatures="false" includeLaunchers="true"> + + <aboutInfo> + <image path="product_lg.gif"/> + <text> + RCP Mail template created by PDE with p2 Discovery support + </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.cloud" /> + <launcher name="cloud"> + <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.ds"/> + <plugin id="org.eclipse.equinox.event"/> + <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.discovery"/> + <plugin id="org.eclipse.equinox.p2.discovery.compatibility"/> + <plugin id="org.eclipse.equinox.p2.engine"/> + <plugin id="org.eclipse.equinox.p2.examples.rcp.cloud" version="2.0.0.qualifier"/> + <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.operations"/> + <plugin id="org.eclipse.equinox.p2.publisher"/> + <plugin id="org.eclipse.equinox.p2.ql"/> + <plugin id="org.eclipse.equinox.p2.repository"/> + <plugin id="org.eclipse.equinox.p2.touchpoint.eclipse"/> + <plugin id="org.eclipse.equinox.p2.touchpoint.natives"/> + <plugin id="org.eclipse.equinox.p2.ui"/> + <plugin id="org.eclipse.equinox.p2.ui.discovery"/> + <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.equinox.util"/> + <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.gtk.linux.x86" fragment="true"/> + <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/> + <plugin id="org.eclipse.ui"/> + <plugin id="org.eclipse.ui.browser"/> + <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.discovery/icons/mail-screenshot.png b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail-screenshot.png Binary files differnew file mode 100644 index 000000000..d6a8a0ea9 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail-screenshot.png diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail.ico b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail.ico Binary files differnew file mode 100644 index 000000000..b00006113 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail.ico diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail.png b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail.png Binary files differnew file mode 100644 index 000000000..d88869829 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mail.png diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mpc-screenshot.png b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mpc-screenshot.png Binary files differnew file mode 100644 index 000000000..3c1f04629 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mpc-screenshot.png diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mpc.png b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mpc.png Binary files differnew file mode 100644 index 000000000..f135e36e1 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/mpc.png diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/pop3.png b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/pop3.png Binary files differnew file mode 100644 index 000000000..8de654ae4 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/pop3.png diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample.gif b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample.gif Binary files differnew file mode 100644 index 000000000..34fb3c9d8 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample.icns b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample.icns Binary files differnew file mode 100644 index 000000000..1e92ccce1 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample.icns diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample2.gif b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample2.gif Binary files differnew file mode 100644 index 000000000..252d7ebcb --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample2.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample3.gif b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample3.gif Binary files differnew file mode 100644 index 000000000..b949ac948 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/icons/sample3.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/p2.inf b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/p2.inf new file mode 100644 index 000000000..48f31a324 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/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.discovery/plugin.properties b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/plugin.properties new file mode 100644 index 000000000..cdf457c0e --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/plugin.properties @@ -0,0 +1,19 @@ +############################################################################### +# 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 +installedSoftwarePage = Installed Software +installHistoryPage = Installation History diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/plugin.xml b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/plugin.xml new file mode 100644 index 000000000..bff2bb0e7 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/plugin.xml @@ -0,0 +1,210 @@ +<?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.cloud.Application"> + </run> + </application> + </extension> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + name="RCP Perspective" + class="org.eclipse.equinox.p2.examples.rcp.cloud.Perspective" + id="org.eclipse.equinox.p2.examples.rcp.cloud.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.cloud.View" + id="org.eclipse.equinox.p2.examples.rcp.cloud.view"> + </view> + <view + name="Mailboxes" + allowMultiple="true" + icon="icons/sample3.gif" + class="org.eclipse.equinox.p2.examples.rcp.cloud.NavigationView" + id="org.eclipse.equinox.p2.examples.rcp.cloud.navigationView"> + </view> + </extension> + <extension + point="org.eclipse.ui.commands"> + <category + name="Mail" + id="org.eclipse.equinox.p2.examples.rcp.cloud.category"> + </category> + <command + name="Open Mailbox" + description="Opens a mailbox" + categoryId="org.eclipse.equinox.p2.examples.rcp.cloud.category" + id="org.eclipse.equinox.p2.examples.rcp.cloud.open"> + </command> + <command + name="Open Message Dialog" + description="Open a message dialog" + categoryId="org.eclipse.equinox.p2.examples.rcp.cloud.category" + id="org.eclipse.equinox.p2.examples.rcp.cloud.openMessage"> + </command> + </extension> + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="org.eclipse.equinox.p2.examples.rcp.cloud.open" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="CTRL+2"> + </key> + <key + commandId="org.eclipse.equinox.p2.examples.rcp.cloud.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.cloud.application" + name="RCP Mail Example (p2 Discovery)"> + <property + name="aboutText" + value="RCP Mail template created by PDE with p2 Discovery support"> + </property> + <property + name="windowImages" + value="icons/sample2.gif"> + </property> + <property + name="aboutImage" + value="product_lg.gif"> + </property> + <property + name="appName" + value="RCP Mail Example (p2 Discovery)"> + </property> + </product> + </extension> + <extension + point="org.eclipse.ui.installationPages"> + <page + name="%installedSoftwarePage" + class="org.eclipse.equinox.p2.ui.InstalledSoftwarePage" + id="10.org.eclipse.equinox.p2.examples.rcp.cloud.InstalledSoftwarePage"> + </page> + <page + name="%installHistoryPage" + class="org.eclipse.equinox.p2.ui.RevertProfilePage" + id="11.org.eclipse.equinox.p2.examples.rcp.cloud.RevertProfilePage"> + </page> + + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + name="%Update.command" + id="org.eclipse.equinox.p2.examples.rcp.cloud.command.update"> + </command> + </extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + commandId="org.eclipse.equinox.p2.examples.rcp.cloud.command.update" + class="org.eclipse.equinox.p2.examples.rcp.cloud.p2.UpdateHandler"> + </handler> + <handler + commandId="org.eclipse.equinox.p2.examples.rcp.cloud.command.install" + class="org.eclipse.equinox.p2.examples.rcp.cloud.p2.InstallNewSoftwareHandler"> + </handler> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + locationURI="menu:tools?after=additions"> + <command + commandId="org.eclipse.equinox.p2.ui.discovery.commands.ShowBundleCatalog" + label="Install Extensions..." + style="push"> + </command> + <command + commandId="org.eclipse.equinox.p2.examples.rcp.cloud.command.update" + mnemonic="%Update.command.mnemonic" + id="org.eclipse.equinox.p2.examples.rcp.cloud.menu.update"> + </command> + + </menuContribution> + </extension> + <extension + point="org.eclipse.mylyn.discovery.core.connectorDiscovery"> + <connectorCategory + description="Extensions for additional email protocols." + id="org.eclipse.equinox.p2.examples.rcp.cloud.category.protocols" + name="Email Protocol Support"> + </connectorCategory> + <connectorDescriptor + categoryId="org.eclipse.equinox.p2.examples.rcp.cloud.category.protocols" + description="Sample extension that provides support for the IMAP protocol." + id="org.eclipse.equinox.p2.examples.rcp.cloud.extensions.imap" + kind="task" + license="EPL" + name="IMAP protocol support" + provider="Eclipse.org" + siteUrl="http://www.eclipse.org/equinox/p2/testing/updateSite"> + <icon + image32="icons/mail.png"> + </icon> + </connectorDescriptor> + <connectorDescriptor + categoryId="org.eclipse.equinox.p2.examples.rcp.cloud.category.protocols" + description="Sample extension that provides support for the POP3 protocol." + id="org.eclipse.equinox.p2.examples.rcp.cloud.extensions.pop" + kind="task" + license="EPL" + name="POP3 protocol support" + provider="Eclipse.org" + siteUrl="http://www.eclipse.org/equinox/p2/testing/updateSite"> + <overview + screenshot="icons/mail-screenshot.png" + summary="In computing, the Post Office Protocol (POP) is an application-layer Internet standard protocol used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection. POP and IMAP (Internet Message Access Protocol) are the two most prevalent Internet standard protocols for e-mail retrieval. Virtually all modern e-mail clients and servers support both. The POP protocol has been developed through several versions, with version 3 (POP3) being the current standard." + url="http://en.wikipedia.org/wiki/Post_Office_Protocol"> + </overview> + <icon + image32="icons/mail.png"> + </icon> + </connectorDescriptor> + <connectorCategory + description="Other extensions for the RCP Mail application." + id="org.eclipse.equinox.p2.examples.rcp.cloud.category.misc" + name="Tools"> + </connectorCategory> + <connectorDescriptor + categoryId="org.eclipse.equinox.p2.examples.rcp.cloud.category.misc" + description="Another example of integrating p2 discovery." + id="org.eclipse.epp.mpc" + kind="task" + license="EPL" + name="Eclipse Marketplace Client" + provider="Eclipse Packaging Project" + siteUrl="http://download.eclipse.org/releases/staging"> + <overview + screenshot="icons/mpc-screenshot.png" + summary="Marketplace Client is a rich client solution for installing solutions listed on Eclipse Marketplace directly from an Eclipse Installation.

The Eclipse community has hundreds, if not thousands, of third-party plugins that users can add to their Eclipse installation. Unfortunately, there is not easy way to discover and install these solutions from within Eclipse.

The Eclipse Foundation has recently launched a new website, called Eclipse Marketplace, that provides a listing of Eclipse-based solutions. The listings allow each solution provider to specify a P2 repository for their solution. Eclipse users now have a central catalog to find Eclipse solutions but the install process is still not tightly integrated with the Eclipse workspace.

MPC provides the tight install integration between the Eclipse workspace and Eclipse Marketplace, plus other third party solution listings. MPC is included in many of the EPP packages." + url="http://eclipse.org/mpc/"></overview> + <icon + image32="icons/mpc.png"> + </icon> + </connectorDescriptor> + </extension> +</plugin> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/pom.xml b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/pom.xml new file mode 100644 index 000000000..87471e819 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/pom.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>org.eclipse.equinox.p2-parent</artifactId> + <groupId>org.eclipse</groupId> + <version>0.0.1-SNAPSHOT</version><relativePath>../org.eclipse.equinox.p2-parent</relativePath> + </parent> + <groupId>org.eclipse</groupId> + <artifactId>org.eclipse.equinox.p2.examples.rcp.cloud</artifactId> + <version>2.0.0.qualifier</version> + <packaging>eclipse-plugin</packaging> +</project> diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/product_lg.gif b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/product_lg.gif Binary files differnew file mode 100644 index 000000000..bd95e283f --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/product_lg.gif diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/splash.bmp b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/splash.bmp Binary files differnew file mode 100644 index 000000000..d7d2e3032 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/splash.bmp diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java new file mode 100644 index 000000000..c0589471a --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java @@ -0,0 +1,76 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +import org.eclipse.equinox.p2.examples.rcp.cloud.p2.CloudPolicy; +import org.eclipse.equinox.p2.ui.Policy; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +/** + * 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.cloud"; + + // The shared instance + private static Activator plugin; + + ServiceRegistration policyRegistration; + + /** + * 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; + /// XXX register the p2 UI policy + registerP2Policy(context); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + // XXX unregister the UI policy + policyRegistration.unregister(); + policyRegistration = 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); + } + + private void registerP2Policy(BundleContext context) { + policyRegistration = context.registerService(Policy.class.getName(), new CloudPolicy(), null); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java new file mode 100644 index 000000000..cf495c34d --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Application.java @@ -0,0 +1,45 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java new file mode 100644 index 000000000..8064f403c --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationActionBarAdvisor.java @@ -0,0 +1,108 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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); + // XXX add a group for new other tools contributions + 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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java new file mode 100644 index 000000000..717a4fa7c --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,21 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 000000000..a71e1b3f2 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,30 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ICommandIds.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ICommandIds.java new file mode 100644 index 000000000..6bf884ccb --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/ICommandIds.java @@ -0,0 +1,15 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +/** + * 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.cloud.open"; + public static final String CMD_OPEN_MESSAGE = "org.eclipse.equinox.p2.examples.rcp.cloud.openMessage"; + +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java new file mode 100644 index 000000000..85324bae0 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/MessagePopupAction.java @@ -0,0 +1,25 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.cloud.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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java new file mode 100644 index 000000000..c58a55812 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/NavigationView.java @@ -0,0 +1,151 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.cloud.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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java new file mode 100644 index 000000000..317e07342 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/OpenViewAction.java @@ -0,0 +1,36 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.cloud.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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java new file mode 100644 index 000000000..63299ce7e --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/Perspective.java @@ -0,0 +1,25 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.cloud.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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java new file mode 100644 index 000000000..d215e5b2c --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/View.java @@ -0,0 +1,77 @@ +package org.eclipse.equinox.p2.examples.rcp.cloud; + +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.cloud.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.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java new file mode 100644 index 000000000..c5b754f93 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.cloud.p2; + +import org.eclipse.equinox.p2.ui.Policy; + +/** + * CloudPolicy defines the RCP Cloud Example policies for the p2 UI. The policy + * is registered as an OSGi service when the example bundle starts. + * + * @since 3.5 + */ +public class CloudPolicy extends Policy { + public CloudPolicy() { + // XXX User has no visibility for repos + setRepositoriesVisible(false); + + // XXX Default view is by category + setGroupByCategory(true); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java new file mode 100644 index 000000000..06643cca1 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/InstallNewSoftwareHandler.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.cloud.p2; + +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; + +/** + * InstallNewSoftwareHandler invokes the install wizard + * + * @since 3.5 + */ +public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler { + + /** + * The constructor. + */ + public InstallNewSoftwareHandler() { + super(); + } + + protected void doExecute(LoadMetadataRepositoryJob job) { + getProvisioningUI().openInstallWizard(null, null, job); + } + + protected boolean waitForPreload() { + // If the user cannot see 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 !getProvisioningUI().getPolicy().getRepositoriesVisible(); + } + + protected void setLoadJobProperties(Job loadJob) { + super.setLoadJobProperties(loadJob); + // If we are doing a background load, we do not wish to authenticate, as the + // user is unaware that loading was needed + if (!waitForPreload()) { + loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true)); + loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true)); + } + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java new file mode 100644 index 000000000..a4c4710a2 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreloadingRepositoryHandler.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * 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.cloud.p2; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; +import org.eclipse.equinox.p2.ui.ProvisioningUI; +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 { + + /** + * The constructor. + */ + public PreloadingRepositoryHandler() { + // constructor + } + + /** + * Execute the command. + */ + public Object execute(ExecutionEvent event) { + doExecuteAndLoad(); + return null; + } + + void doExecuteAndLoad() { + if (preloadRepositories()) { + //cancel any load that is already running + Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY); + final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()); + setLoadJobProperties(loadJob); + 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(loadJob); + } + }); + } + } + }); + loadJob.setUser(true); + loadJob.schedule(); + + } else { + loadJob.setSystem(true); + loadJob.setUser(false); + loadJob.schedule(); + doExecute(null); + } + } else { + doExecute(null); + } + } + + protected abstract void doExecute(LoadMetadataRepositoryJob job); + + protected boolean preloadRepositories() { + return true; + } + + protected boolean waitForPreload() { + return true; + } + + protected void setLoadJobProperties(Job loadJob) { + loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true)); + } + + protected ProvisioningUI getProvisioningUI() { + return ProvisioningUI.getDefaultUI(); + } + + /** + * Return a shell appropriate for parenting dialogs of this handler. + * @return a Shell + */ + protected Shell getShell() { + return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); + } +} diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java new file mode 100644 index 000000000..e484212a0 --- /dev/null +++ b/examples/org.eclipse.equinox.p2.examples.rcp.discovery/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/UpdateHandler.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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.cloud.p2; + +import org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard; +import org.eclipse.equinox.p2.operations.RepositoryTracker; +import org.eclipse.equinox.p2.operations.UpdateOperation; +import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; +import org.eclipse.jface.wizard.WizardDialog; + +/** + * UpdateHandler invokes the check for updates UI + * + * @since 3.4 + */ +public class UpdateHandler extends PreloadingRepositoryHandler { + + boolean hasNoRepos = false; + + protected void doExecute(LoadMetadataRepositoryJob job) { + if (hasNoRepos) { + return; + } + UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null); + // check for updates + operation.resolveModal(null); + if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) { + if (UpdateSingleIUWizard.validFor(operation)) { + // Special case for only updating a single root + UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation); + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.create(); + dialog.open(); + } else { + // Open the normal version of the update wizard + getProvisioningUI().openUpdateWizard(false, operation, job); + } + } + } + + protected boolean preloadRepositories() { + hasNoRepos = false; + RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker(); + if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) { + hasNoRepos = true; + return false; + } + return super.preloadRepositories(); + } +} |