Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-05-04 00:40:58 -0400
committerSusan Franklin2010-05-04 00:40:58 -0400
commit984cca2433c1a0e095373469f30042b3b1a293cf (patch)
tree76aab51daaed882aa45d0f300a611b9e0a1fd6fc /examples
parentc5dc063bad9968448b60fbd50b65eaed8aac815e (diff)
downloadrt.equinox.p2-984cca2433c1a0e095373469f30042b3b1a293cf.tar.gz
rt.equinox.p2-984cca2433c1a0e095373469f30042b3b1a293cf.tar.xz
rt.equinox.p2-984cca2433c1a0e095373469f30042b3b1a293cf.zip
Bug 290973 - [ui] [example] RCP Simple Update UI Example
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/cloud.product.launch33
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin.xml6
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin_customization.ini40
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java26
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java31
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceConstants.java21
-rw-r--r--examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceInitializer.java46
7 files changed, 193 insertions, 10 deletions
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/cloud.product.launch b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/cloud.product.launch
new file mode 100644
index 000000000..289cbe1b2
--- /dev/null
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/cloud.product.launch
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
+<booleanAttribute key="append.args" value="true"/>
+<stringAttribute key="application" value="org.eclipse.equinox.p2.examples.rcp.cloud.application"/>
+<booleanAttribute key="askclear" value="true"/>
+<booleanAttribute key="automaticAdd" value="false"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="false"/>
+<booleanAttribute key="clearws" value="false"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/cloud.product"/>
+<booleanAttribute key="default" value="false"/>
+<booleanAttribute key="generateProfile" value="true"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../runtime-cloud.product"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx384m"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.equinox.p2.examples.rcp.cloud.product"/>
+<stringAttribute key="productFile" value="\org.eclipse.equinox.p2.examples.rcp.cloud\cloud.product"/>
+<stringAttribute key="selected_target_plugins" value="org.eclipse.osgi@-1:true,org.eclipse.core.databinding@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.equinox.security.win32.x86@default:false,org.eclipse.core.variables@default:default,org.apache.commons.logging@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.security.ui@default:default,org.eclipse.equinox.app@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.ecf@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.equinox.ds@1:true,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.osgi.services@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.swt.win32.win32.x86@default:false,org.eclipse.core.runtime.compatibility.auth@default:default,org.apache.commons.httpclient@default:default,org.eclipse.core.net.win32.x86@default:false,javax.servlet@default:default,org.eclipse.ant.core@default:default,org.eclipse.equinox.util@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.help@default:default,org.eclipse.core.databinding.observable@default:default,com.ibm.icu@default:default,org.apache.commons.codec@default:default,org.eclipse.ui.browser@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.core.expressions@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.swt@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.event@default:default,org.eclipse.core.net@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.commands@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.sat4j.core@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.p2.examples.rcp.cloud*1.0.0.qualifier@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.ui@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.jface@default:default,org.sat4j.pb@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.jface.databinding@default:default"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<booleanAttribute key="useProduct" value="true"/>
+<booleanAttribute key="usefeatures" value="false"/>
+</launchConfiguration>
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin.xml b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin.xml
index 391eaf34f..7e1298fb6 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin.xml
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin.xml
@@ -95,7 +95,11 @@
</product>
</extension>
- <extension
+ <extension
+ id="preferences" point="org.eclipse.core.runtime.preferences" name="%preferences">
+ <initializer class="org.eclipse.equinox.p2.examples.rcp.cloud.p2.PreferenceInitializer"/>
+ </extension>
+ <extension
point="org.eclipse.ui.installationPages">
<page
name="%installedSoftwarePage"
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin_customization.ini b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin_customization.ini
index 7a9e388f4..4fc0faec8 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin_customization.ini
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/plugin_customization.ini
@@ -1 +1,39 @@
-org.eclipse.equinox.p2.ui.sdk.scheduler/enabled=true \ No newline at end of file
+# we can configure the update UI by using application preferences to initialize the default UI policy
+
+# should user be able to see and manipulate repositories in the install wizard
+org.eclipse.equinox.p2.examples.rcp.cloud/repositoriesVisible=false
+
+# force restart after a provisioning operation (see possible values in org.eclipse.equinox.p2.ui.Policy.restartPolicy())
+org.eclipse.equinox.p2.examples.rcp.cloud/restartPolicy=1
+
+# show only latest versions when browsing for updates
+org.eclipse.equinox.p2.examples.rcp.cloud/showLatestVersionOnly=true
+
+# software should be grouped by category by default
+org.eclipse.equinox.p2.examples.rcp.cloud/groupByCategory=true
+
+# show only groups (features) in the available list, not every bundle
+org.eclipse.equinox.p2.examples.rcp.cloud/showAllBundlesAvailable=false
+
+# show only the install roots in the installed software list
+org.eclipse.equinox.p2.examples.rcp.cloud/showAllBundlesInstalled=true
+
+# do not drilldown into requirements in the wizards, just show the high level things
+org.eclipse.equinox.p2.examples.rcp.cloud/showDrilldownRequirements=false
+
+# automatic update options are defined in org.eclipse.equinox.p2.sdk.scheduler.PreferenceConstants
+
+# check for updates on startup
+org.eclipse.equinox.p2.ui.sdk.scheduler/enabled=true
+org.eclipse.equinox.p2.ui.sdk.scheduler/schedule=on-startup
+
+# remind the user every 4 hours
+org.eclipse.equinox.p2.ui.sdk.scheduler/remindOnSchedule=true
+# see AutomaticUpdatesPopup, values can be "30 minutes", "Hour", "4 Hours"
+org.eclipse.equinox.p2.ui.sdk.scheduler/remindElapsedTime=4 Hours
+
+# download updates before notifying the user
+org.eclipse.equinox.p2.ui.sdk.scheduler/download=true
+
+
+
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java
index c0589471a..df16caf86 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/Activator.java
@@ -2,7 +2,10 @@ 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.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
@@ -19,6 +22,9 @@ public class Activator extends AbstractUIPlugin {
private static Activator plugin;
ServiceRegistration policyRegistration;
+ CloudPolicy policy;
+ IPropertyChangeListener preferenceListener;
+
/**
* The constructor
@@ -33,8 +39,20 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- /// XXX register the p2 UI policy
+ // XXX register the p2 UI policy
registerP2Policy(context);
+ getPreferenceStore().addPropertyChangeListener(getPreferenceListener());
+ }
+
+ private IPropertyChangeListener getPreferenceListener() {
+ if (preferenceListener == null) {
+ preferenceListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ policy.updateForPreferences();
+ }
+ };
+ }
+ return preferenceListener;
}
/*
@@ -46,6 +64,8 @@ public class Activator extends AbstractUIPlugin {
// XXX unregister the UI policy
policyRegistration.unregister();
policyRegistration = null;
+ getPreferenceStore().removePropertyChangeListener(preferenceListener);
+ preferenceListener = null;
super.stop(context);
}
@@ -71,6 +91,8 @@ public class Activator extends AbstractUIPlugin {
}
private void registerP2Policy(BundleContext context) {
- policyRegistration = context.registerService(Policy.class.getName(), new CloudPolicy(), null);
+ policy = new CloudPolicy();
+ policy.updateForPreferences();
+ policyRegistration = context.registerService(Policy.class.getName(), policy, null);
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java
index c5b754f93..d2df4a112 100644
--- a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/CloudPolicy.java
@@ -10,7 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.examples.rcp.cloud.p2;
+import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
+import org.eclipse.equinox.p2.examples.rcp.cloud.Activator;
+import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.ui.Policy;
+import org.eclipse.jface.preference.IPreferenceStore;
/**
* CloudPolicy defines the RCP Cloud Example policies for the p2 UI. The policy
@@ -19,11 +23,26 @@ import org.eclipse.equinox.p2.ui.Policy;
* @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);
+
+ public void updateForPreferences() {
+ IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
+ setRepositoriesVisible(prefs
+ .getBoolean(PreferenceConstants.REPOSITORIES_VISIBLE));
+ setRestartPolicy(prefs.getInt(PreferenceConstants.RESTART_POLICY));
+ setShowLatestVersionsOnly(prefs
+ .getBoolean(PreferenceConstants.SHOW_LATEST_VERSION_ONLY));
+ setGroupByCategory(prefs
+ .getBoolean(PreferenceConstants.AVAILABLE_GROUP_BY_CATEGORY));
+ setShowDrilldownRequirements(prefs
+ .getBoolean(PreferenceConstants.SHOW_DRILLDOWN_REQUIREMENTS));
+ if (prefs.getBoolean(PreferenceConstants.AVAILABLE_SHOW_ALL_BUNDLES))
+ setVisibleAvailableIUQuery(QueryUtil.ALL_UNITS);
+ else
+ setVisibleAvailableIUQuery(QueryUtil.createIUGroupQuery());
+ if (prefs.getBoolean(PreferenceConstants.INSTALLED_SHOW_ALL_BUNDLES))
+ setVisibleAvailableIUQuery(QueryUtil.ALL_UNITS);
+ else
+ setVisibleAvailableIUQuery(new UserVisibleRootQuery());
+
}
}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceConstants.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceConstants.java
new file mode 100644
index 000000000..b4b72e5c1
--- /dev/null
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceConstants.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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;
+
+public class PreferenceConstants {
+ public static final String RESTART_POLICY = "restartPolicy"; //$NON-NLS-1$
+ public static final String SHOW_LATEST_VERSION_ONLY = "showLatestVersionOnly"; //$NON-NLS-1$
+ public static final String AVAILABLE_GROUP_BY_CATEGORY = "groupByCategory"; //$NON-NLS-1$
+ public static final String AVAILABLE_SHOW_ALL_BUNDLES = "showAllBundlesAvailable"; //$NON-NLS-1$
+ public static final String INSTALLED_SHOW_ALL_BUNDLES = "showAllBundlesInstalled"; //$NON-NLS-1$
+ public static final String REPOSITORIES_VISIBLE = "repositoriesVisible"; //$NON-NLS-1$
+ public static final String SHOW_DRILLDOWN_REQUIREMENTS = "showDrilldownRequirements"; //$NON-NLS-1$
+}
diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceInitializer.java b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceInitializer.java
new file mode 100644
index 000000000..8ba7ae8d5
--- /dev/null
+++ b/examples/org.eclipse.equinox.p2.examples.rcp.cloud/src/org/eclipse/equinox/p2/examples/rcp/cloud/p2/PreferenceInitializer.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.*;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.engine.ProfileScope;
+import org.eclipse.equinox.p2.examples.rcp.cloud.Activator;
+import org.eclipse.equinox.p2.ui.Policy;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * @since 3.6
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ Preferences node = new DefaultScope().getNode(Activator.PLUGIN_ID); //$NON-NLS-1$
+ // default values
+ node.putBoolean(PreferenceConstants.REPOSITORIES_VISIBLE, false);
+ node.putBoolean(PreferenceConstants.SHOW_LATEST_VERSION_ONLY, true);
+ node.putBoolean(PreferenceConstants.AVAILABLE_SHOW_ALL_BUNDLES, false);
+ node.putBoolean(PreferenceConstants.INSTALLED_SHOW_ALL_BUNDLES, false);
+ node.putBoolean(PreferenceConstants.AVAILABLE_GROUP_BY_CATEGORY, true);
+ node.putBoolean(PreferenceConstants.SHOW_DRILLDOWN_REQUIREMENTS, false);
+ node.putInt(PreferenceConstants.RESTART_POLICY, Policy.RESTART_POLICY_PROMPT_RESTART_OR_APPLY);
+ }
+}

Back to the top