Skip to content

Commit

Permalink
Migrate AutomaticUpdateScheduler from IStartup to OSGi EventHandler
Browse files Browse the repository at this point in the history
... for the UIEvents.UILifeCycle.APP_STARTUP_COMPLETE event.

This is a less Eclipse specific approach and also prevents the user from
disabling the start-up task.
The automatic search for updates can still be disabled.
  • Loading branch information
HannesWell committed Jan 19, 2024
1 parent 61dd705 commit b3215ef
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ bin/
.META-INF_*
pom.tycho
.tycho-consumer-pom.xml
apiAnalyzer-workspace/
apiAnalyzer-workspace/

#Generated OSGi declarative service files
**/OSGI-INF/org.eclipse.*.xml
1 change: 0 additions & 1 deletion bundles/org.eclipse.equinox.p2.core/OSGI-INF/.gitignore

This file was deleted.

5 changes: 5 additions & 0 deletions bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/.project
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dsVersion=V1_4
eclipse.preferences.version=1
enabled=true
generateBundleActivationPolicyLazy=true
path=OSGI-INF
validationErrorLevel=error
validationErrorLevel.missingImplicitUnbindMethod=error
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.equinox.internal.p2.ui.sdk.scheduler;x-internal:=true,
org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration;x-internal:=true
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.equinox.p2.updatechecker,
org.eclipse.equinox.p2.ui,
org.eclipse.equinox.p2.repository;bundle-version="2.3.0"
org.eclipse.equinox.p2.repository;bundle-version="2.3.0",
org.eclipse.e4.ui.workbench;bundle-version="[1.15.0,2.0.0)",
org.eclipse.ui.workbench;bundle-version="[3.131.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.33.0,4.0.0)"
Service-Component: OSGI-INF/org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdateScheduler.xml
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.engine,
org.eclipse.equinox.internal.p2.engine.phases,
org.eclipse.equinox.internal.p2.garbagecollector,
org.eclipse.equinox.internal.p2.metadata.query,
org.eclipse.equinox.internal.p2.touchpoint.eclipse;version="2.0.0",
org.eclipse.equinox.internal.p2.ui,
org.eclipse.equinox.internal.p2.ui.actions,
org.eclipse.equinox.internal.p2.ui.query,
org.eclipse.equinox.internal.provisional.p2.core.eventbus,
org.eclipse.equinox.internal.provisional.p2.repository,
org.eclipse.equinox.internal.provisional.p2.updatechecker,
org.eclipse.equinox.p2.core;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)",
Expand All @@ -34,8 +33,8 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.p2.operations;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.query;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.ui;version="[2.0.0,3.0.0)",
org.eclipse.osgi.service.resolver;version="1.1.0",
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.6.0",
org.osgi.service.packageadmin;version="1.2.0"
org.osgi.service.event;version="[1.4.0,2.0.0)",
org.osgi.service.event.propertytypes;version="1.4.0"
Automatic-Module-Name: org.eclipse.equinox.p2.ui.sdk.scheduler
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
bin.includes = plugin.properties,\
icons/,\
.,\
OSGI-INF/,\
about.html,\
META-INF/,\
plugin.xml
Expand Down
5 changes: 0 additions & 5 deletions bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
id="preferences" point="org.eclipse.core.runtime.preferences" name="%automaticUpdatesPrefPage">
<initializer class="org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceInitializer"/>
</extension>
<extension
point="org.eclipse.ui.startup">
<startup class="org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdateScheduler">
</startup>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Random;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.garbagecollector.GarbageCollector;
import org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration.MigrationSupport;
Expand All @@ -32,16 +33,21 @@
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.osgi.service.event.propertytypes.EventTopics;

/**
* This plug-in is loaded on startup to register with the update checker.
*
* @since 3.5
*/
public class AutomaticUpdateScheduler implements IStartup {
@Component(service = EventHandler.class)
@EventTopics(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE)
public class AutomaticUpdateScheduler implements EventHandler {
public static final String MIGRATION_DIALOG_SHOWN = "migrationDialogShown"; //$NON-NLS-1$

public static final String P_FUZZY_RECURRENCE = "fuzzy_recurrence"; //$NON-NLS-1$
Expand All @@ -56,7 +62,7 @@ public class AutomaticUpdateScheduler implements IStartup {
private IUpdateChecker checker;

@Override
public void earlyStartup() {
public void handleEvent(Event event) {
AutomaticUpdatePlugin.getDefault().setScheduler(this);

Job updateJob = new Job("Update Job") { //$NON-NLS-1$
Expand Down

0 comments on commit b3215ef

Please sign in to comment.