Project

General

Profile

hc_diff20141129a.diff

Hynek Cihlar, 11/29/2014 10:48 AM

Download (2.35 KB)

View differences:

src/com/goldencode/p2j/ui/ConfigManager.java
385 385
    */
386 386
   public void addWidgetConfig(WidgetConfig config)
387 387
   {
388
      WidgetId id = config.id;
388
      addWidgetConfig(config, null);
389
   }
390
   
391
   // TODO: doc 
392
   //       activeConfig must not be null; backupConfig may be null, in this case
393
   //       activeConfig will be used as backup.
394
   public void addWidgetConfig(WidgetConfig activeConfig, WidgetConfig backupConfig)
395
   {
396
      WidgetId id = activeConfig.id;
389 397
      
390 398
      if (getActiveConfig(id) != null)
391 399
      {
392 400
         throw new RuntimeException("A configuration is already associated for " + 
393
                                    config.toString());
401
                                    activeConfig.toString());
394 402
      }
395 403

  
396
      WidgetConfig backup = duplicate(config);
404
      backupConfig = backupConfig != null ? duplicate(backupConfig) : duplicate(activeConfig);
405
      
397 406
      // the backup doesn't have an ID, because we don't want to access the widget
398
      backup.id = null;
407
      backupConfig.id = null;
399 408

  
400
      WidgetConfigDef wdef = getConfigDef(config.getClass());
409
      WidgetConfigDef wdef = getConfigDef(activeConfig.getClass());
401 410
      
402 411
      widgetCfg.put(id, wdef);
403
      activeConfigs.put(id, config);
404
      backupConfigs.put(id, backup);
412
      activeConfigs.put(id, activeConfig);
413
      backupConfigs.put(id, backupConfig);
405 414
   }
406 415

  
407 416
   /**
src/com/goldencode/p2j/ui/client/WidgetRegistry.java
109 109

  
110 110
            WidgetConfig wcfg = comp.config();
111 111
            
112
            ConfigManager.getInstance().addWidgetConfig(wcfg);
112
            // Save the base state, during initialization the widget/config state may change.
113
            // Without the proper base state the changes would not be sent to the server.
114
            ConfigManager.getInstance().addWidgetConfig(wcfg, config);
113 115
         }
114 116
      }
115 117