Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate AutomaticUpdateScheduler from IStartup to OSGi EventHandler #400

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ bin/
pom.tycho
.tycho-consumer-pom.xml
.flattened-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 @@ -2,30 +2,29 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.equinox.p2.ui.sdk.scheduler;singleton:=true
Bundle-Version: 1.6.300.qualifier
Bundle-Version: 1.6.400.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdatePlugin
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.12.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,2.0.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 @@ -33,16 +34,21 @@
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
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 @@ -57,7 +63,7 @@ public class AutomaticUpdateScheduler implements IStartup {
private IUpdateChecker checker;

@Override
public void earlyStartup() {
public void handleEvent(Event event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check if automated updates are disabled before starting the job?

AutomaticUpdatePlugin.getDefault().setScheduler(this);

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