TUP-2219 : Allow features installed dynamically to be checked for updates

This commit is contained in:
Sebastien Gandon
2014-09-18 16:31:54 +02:00
parent ee919ef45a
commit a962ef98cc
10 changed files with 45 additions and 65 deletions

View File

@@ -0,0 +1,9 @@
package org.talend.updates.runtime;
public class Constants {
// The plug-in ID
public static final String PLUGIN_ID = "org.talend.updates.runtime"; //$NON-NLS-1$
}

View File

@@ -1,50 +0,0 @@
package org.talend.updates.runtime;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class UpdatesRuntimePlugin extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.talend.updates.runtime"; //$NON-NLS-1$
// The shared instance
private static UpdatesRuntimePlugin plugin;
/**
* The constructor
*/
public UpdatesRuntimePlugin() {
}
/*
* (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;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static UpdatesRuntimePlugin getDefault() {
return plugin;
}
}

View File

@@ -73,11 +73,11 @@ public class ExtraFeaturesUpdatesFactory {
}
}
public void afterUpdate() throws Exception {
public void afterCompleteInstall() throws Exception {
AbstractExtraUpdatesFactory[] updatesFactories = updatesFactoryReader.getUpdatesFactories();
if (updatesFactories != null) {
for (AbstractExtraUpdatesFactory factory : updatesFactories) {
factory.afterUpdate();
factory.afterCompleteInstall();
}
}
}

View File

@@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.SafeRunner;
import org.talend.core.utils.RegistryReader;
import org.talend.updates.runtime.UpdatesRuntimePlugin;
import org.talend.updates.runtime.Constants;
import org.talend.updates.runtime.engine.factory.AbstractExtraUpdatesFactory;
/**
@@ -37,7 +37,7 @@ public class ExtraFeaturesUpdatesReader extends RegistryReader {
private AbstractExtraUpdatesFactory[] factories;
public ExtraFeaturesUpdatesReader() {
super(UpdatesRuntimePlugin.PLUGIN_ID, "extraUpdatesFactory"); //$NON-NLS-1$
super(Constants.PLUGIN_ID, "extraUpdatesFactory"); //$NON-NLS-1$
init();
}

View File

@@ -67,9 +67,10 @@ public abstract class AbstractExtraUpdatesFactory {
}
/**
* after update studio, will do this.
* This is called once all the different features of different types have all been installed. This is only called if
* there is at least one feature successfully installed, even if this current feature failed to be installed.
*/
public void afterUpdate() throws Exception {
public void afterCompleteInstall() throws Exception {
// nothing to do
}
}

View File

@@ -19,7 +19,7 @@ import org.eclipse.core.runtime.Status;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.talend.commons.i18n.MessagesCore;
import org.talend.updates.runtime.UpdatesRuntimePlugin;
import org.talend.updates.runtime.Constants;
/**
* created by sgandon on 5 mars 2013 Detailled comment
@@ -39,7 +39,7 @@ public class Messages extends MessagesCore {
* @see MessagesCore#getString(String, ResourceBundle)
*/
public static String getString(String key) {
return getString(key, UpdatesRuntimePlugin.PLUGIN_ID, resourceBundle);
return getString(key, Constants.PLUGIN_ID, resourceBundle);
}
/**
@@ -51,7 +51,7 @@ public class Messages extends MessagesCore {
* @see MessagesCore#getString(String, ResourceBundle, Object[])
*/
public static String getString(String key, Object... args) {
return MessagesCore.getString(key, UpdatesRuntimePlugin.PLUGIN_ID, resourceBundle, args);
return MessagesCore.getString(key, Constants.PLUGIN_ID, resourceBundle, args);
}
/**

View File

@@ -34,6 +34,16 @@ public interface ExtraFeature {
*/
public boolean isInstalled(IProgressMonitor progress) throws Exception;
/**
* Check that the feature has an udpate with a version higher than the one already installed. If that is the case
* then a new instance of ExtraFeature is created, it returns null otherwhise.
*
* @param progress
*
* @return a new feature is an upate is available or null
*/
public ExtraFeature createFeatureIfUpdates(IProgressMonitor progress) throws Exception;
/**
* Getter for name.
*

View File

@@ -249,4 +249,15 @@ public class TalendWebServiceUpdateExtraFeature implements ExtraFeature {
return mustBeInstalled;
}
/*
* (non-Javadoc)
*
* @see
* org.talend.updates.runtime.model.ExtraFeature#createFeatureIfUpdates(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public ExtraFeature createFeatureIfUpdates(IProgressMonitor progress) throws Exception {
return null;// we do not handle udpates yet.
}
}

View File

@@ -34,7 +34,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.osgi.service.prefs.BackingStoreException;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.updates.runtime.UpdatesRuntimePlugin;
import org.talend.updates.runtime.Constants;
import org.talend.updates.runtime.engine.ExtraFeaturesUpdatesFactory;
import org.talend.updates.runtime.engine.InstallNewFeatureJob;
import org.talend.updates.runtime.i18n.Messages;
@@ -56,7 +56,7 @@ public class UpdateStudioWizard extends Wizard {
/**
* preference node for the org.talend.updates plugin.
*/
public static final String ORG_TALEND_UPDATES_PREF_NODE = UpdatesRuntimePlugin.PLUGIN_ID;
public static final String ORG_TALEND_UPDATES_PREF_NODE = Constants.PLUGIN_ID;
UpdateWizardModel updateWizardModel;// model that hold all the parameters set in the wizard
@@ -114,7 +114,7 @@ public class UpdateStudioWizard extends Wizard {
if (hasAnySuccess) {
ExtraFeaturesUpdatesFactory updatesFactory = new ExtraFeaturesUpdatesFactory();
try {
updatesFactory.afterUpdate();
updatesFactory.afterCompleteInstall();
} catch (Exception e) {
hasAnyFailure = true;
}
@@ -151,7 +151,7 @@ public class UpdateStudioWizard extends Wizard {
try {
updatesNode.flush();
} catch (BackingStoreException e) {
log.error("could not store the \"Do No Show this again\" pref of the Install Dialog", e);
log.error("could not store the \"Do No Show this again\" pref of the Install Dialog", e); //$NON-NLS-1$
}
}