private Licence
mapLicence(
Licence licence )
{
Licence existing_licence;
LicenceInstallationListener new_listener = null;
synchronized ( licence_map ){
String key = licence.getKey();
Object[] entry = licence_map.get( key );
if ( entry == null ){
existing_licence = null;
new_listener =
new LicenceInstallationListener()
{
FeatureManagerInstallWindow install_window = null;
public void start(String licence_key) {
if (DEBUG) {
System.out.println("FEATINST: START! " + licence_key);
}
try {
Licence licence = featman.addLicence(licence_key);
install_window = new FeatureManagerInstallWindow(licence);
install_window.open();
} catch (PluginException e) {
Debug.out(e);
}
}
public void reportProgress(String licenceKey, String install, int percent) {
if (DEBUG) {
System.out.println("FEATINST: " + install + ": " + percent);
}
}
public void reportActivity(String licenceKey, String install,
String activity) {
if (DEBUG) {
System.out.println("FEAT: ACTIVITY: " + install + ": " + activity);
}
}
public boolean alreadyFailing = false;
public void failed(String licenceKey, PluginException error) {
if (DEBUG) {
System.out.println("FEAT: FAIL: " + licenceKey + ": " + error.toString());
}
if ( install_window != null ){
install_window.close();
}
if ( licenceKey.equals(pendingAuthForKey)){
pendingAuthForKey = null;
}
if (alreadyFailing) {
return;
}
alreadyFailing = true;
String s = Debug.getNestedExceptionMessage(error);
MessageBoxShell mb = new MessageBoxShell(
SWT.ICON_ERROR | SWT.OK,
"License Addition Error for " + licenceKey,
s );
mb.open( new UserPrompterResultListener() {
public void prompterClosed(int result) {
alreadyFailing = false;
}
} );
}
public void complete(String licenceKey) {
if ( licenceKey.equals(pendingAuthForKey)){
pendingAuthForKey = null;
FeatureManagerUI.openLicenceSuccessWindow();
}
}
};
licence_map.put( key, new Object[]{ licence, new_listener });
}else{
existing_licence = (Licence)entry[0];
entry[0] = licence;
}
}
if ( new_listener != null ){
licence.addInstallationListener( new_listener );
}
return( existing_licence );
}