File: BusyNode.m

package info (click to toggle)
paje.app 1.98-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,428 kB
  • sloc: objc: 24,517; ansic: 6,998; makefile: 134; sh: 42; java: 31
file content (699 lines) | stat: -rw-r--r-- 22,382 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
/*
    Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004 Benhur Stein
    
    This file is part of Paj.

    Paj is free software; you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by the
    Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    Paj is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
    for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Paj; if not, write to the Free Software Foundation, Inc.,
    59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
/* BusyNode.m created by benhur on Fri 27-Feb-1998 */

#include "BusyNode.h"
#include "ReduceEntity.h"
#include "../General/UniqueString.h"
#include "../General/Macros.h"

@implementation BusyNode

- (id)initWithController:(PajeTraceController *)c
{
    self = [super initWithController:c];

    if (self) {

        // load the interface. it initializes view.
        if (![NSBundle loadNibNamed:@"ReductionFilter" owner:self])
            NSRunAlertPanel(NSStringFromClass([self class]),
                            @"Couldn't load interface file",
                            nil, nil, nil);

        // view is an NSBox. we need its contents.
        view = [[view contentView] retain];
#ifndef GNUSTEP
        [[view window] autorelease];
#endif
        [view removeFromSuperview];

        reduceEntityTypes = [[NSMutableSet alloc] init];
        typesContainingReducedTypes = [[NSMutableDictionary alloc] init];
        [self readDefaults];

//        [self registerFilterWithInfo:[NSDictionary dictionaryWithObjectsAndKeys:
//            NSStringFromClass([self class]), @"Name",
//            view, @"View", nil]];
        [self registerFilter:self];
        
    }
    return self;
}

- (NSString *)filterName
{
    return @"Reduction";
}

- (NSView *)filterView
{
    return view;
}

- (void)dealloc
{
    [reduceEntityTypes release];
    [entityTypesDictionary release];
    [typesContainingReducedTypes release];
    [view removeFromSuperview];
    [groupByPopUp removeAllItems];
    [entityTypePopUp removeAllItems];
    //[nameMatrix removeAllItems];
    [entityNamePopUp removeAllItems];
    [view release];
    [super dealloc];
}


- (void)readDefaults
{
    NSString *defaultName;

    defaultName = [NSStringFromClass([self class]) stringByAppendingString:@" ReduceEntityTypes"];
    entityTypesDictionary = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:defaultName] mutableCopy];
    if (entityTypesDictionary == nil) {
        entityTypesDictionary = [[NSMutableDictionary alloc] init];
    }
}

- (void)registerDefaults
{
    NSString *defaultName;

    defaultName = [NSStringFromClass([self class]) stringByAppendingString:@" ReduceEntityTypes"];

    [[NSUserDefaults standardUserDefaults] setObject:entityTypesDictionary
                                              forKey:defaultName];
}

//TODO treat -dataChangedForEntityType:
//- (void)dataChangedForEntityType:(id)entityType
//{
//    [self hierarchyChanged];
//}

- (void)hierarchyChanged
{
    [self calcEntityTypes];
    [self calcEntityNamePopUp];
    [self calcEntityTypePopUp];
    [self calcGroupPopUp];
    [self calcReduceModePopUp];
    [self refreshMatrix];

    [super hierarchyChanged];
}

- (void)calcEntityTypes
{
    NSEnumerator *filterEnum;
    NSDictionary *filter;
    ReduceEntityType *entityType;

    [reduceEntityTypes removeAllObjects];
    filterEnum = [entityTypesDictionary objectEnumerator];
    while ((filter = [filterEnum nextObject]) != nil) {
        entityType = [ReduceEntityType typeFromDictionary:filter component:self];
        if (entityType != nil) {
            [reduceEntityTypes addObject:entityType];
            [self addToHierarchy:entityType];
        }
    }
}

- (void)calcEntityNamePopUp
{
    NSEnumerator *typeEnumerator;
    ReduceEntityType *selectedType;
    ReduceEntityType *type;
    int ct = 0;

    selectedType = [[entityNamePopUp selectedItem] representedObject];
    [entityNamePopUp removeAllItems];
    typeEnumerator = [reduceEntityTypes objectEnumerator];
    while ((type = [typeEnumerator nextObject]) != nil) {
        [entityNamePopUp addItemWithTitle:[type description]];
        [[entityNamePopUp itemWithTitle:[type description]]
                                    setRepresentedObject:type];
	ct++;
    }
    if (ct == 0) {
        [entityNamePopUp addItemWithTitle:@"None"];
        [entityNamePopUp setEnabled:NO];
    } else {
        [entityNamePopUp setEnabled:YES];
    }
    if (selectedType != nil)
        [entityNamePopUp selectItemWithTitle:[selectedType description]];
    if ([entityNamePopUp selectedItem] == nil
        && [entityNamePopUp numberOfItems] > 0)
        [entityNamePopUp selectItemAtIndex:0];
    if ([entityNamePopUp selectedItem] != nil)
        [entityNameField setStringValue:[entityNamePopUp titleOfSelectedItem]];
}

- (void)calcEntityTypePopUp
{
    NSEnumerator *subenum;
    PajeEntityType *entityType;
    ReduceEntityType *type;
    int ct = 0;

    type = [[entityNamePopUp selectedItem] representedObject];
    [entityTypePopUp removeAllItems];
//    subenum = [[inputComponent allEntityTypes] objectEnumerator];
    subenum = [[self allEntityTypes] objectEnumerator];
    while ((entityType = [subenum nextObject]) != nil) {
        if (![self isContainerEntityType:entityType]) {
            NSString *title;
            title = [self descriptionForEntityType:entityType];
            [entityTypePopUp addItemWithTitle:title];
            [[entityTypePopUp itemWithTitle:title]
                                       setRepresentedObject:entityType];
            ct++;
        }
    }
    if (ct == 0) {
        [entityTypePopUp addItemWithTitle:@"None"];
        [entityTypePopUp setEnabled:NO];
    } else {
        [entityTypePopUp setEnabled:YES];
    }
    NSString *selectedTitle;
    selectedTitle = [self descriptionForEntityType:[type entityTypeToReduce]];
    [entityTypePopUp selectItemWithTitle:selectedTitle];
}

- (void)calcGroupPopUp
{
    PajeEntityType *entityType;
    PajeEntityType *parentEntityType;
    ReduceEntityType *type;
    int ct = 0;

    type = [[entityNamePopUp selectedItem] representedObject];
    [groupByPopUp removeAllItems];
    entityType = [type entityTypeToReduce];
    while ((parentEntityType = [self containerTypeForType:entityType]) != nil) {
        if (parentEntityType == entityType) break;
        entityType = parentEntityType;
        NSString *title;
        title = [self descriptionForEntityType:entityType];
        [groupByPopUp insertItemWithTitle:title atIndex:0];
        [[groupByPopUp itemAtIndex:0] setRepresentedObject:entityType];
	ct++;
    }
    if (ct == 0) {
        [groupByPopUp addItemWithTitle:@"None"];
        [groupByPopUp setEnabled:NO];
    } else {
        [groupByPopUp setEnabled:YES];
    }
    NSString *selectedTitle;
    selectedTitle = [self descriptionForEntityType:
                                              [self containerTypeForType:type]];
    [groupByPopUp selectItemWithTitle:selectedTitle];
}

- (void)calcReduceModePopUp
{
    ReduceEntityType *type;
    Class entityClass;
    NSArray *reduceEntityClassNames = [NSArray arrayWithObjects:
        @"CountReduceEntity",
        @"SumReduceEntity",
        @"AverageReduceEntity",
        @"MaxReduceEntity",
        @"MinReduceEntity",
        nil];
    NSEnumerator *classNameEnum;
    NSString *className;
    int ct = 0;
    
    [reduceModePopUp removeAllItems];
    classNameEnum = [reduceEntityClassNames objectEnumerator];
    while ((className = [classNameEnum nextObject]) != nil) {
        entityClass = NSClassFromString(className);
        if (!entityClass) {
            NSWarnMLog(@"class named %@ not found!", className);
            continue;
        }
        [reduceModePopUp addItemWithTitle:[entityClass titleForPopUp]];
        [[reduceModePopUp lastItem] setRepresentedObject:entityClass];
	ct++;
    }
    if (ct == 0) {
    	[reduceModePopUp addItemWithTitle:@"None"];
    	[reduceModePopUp setEnabled:NO];
    } else {
    	[reduceModePopUp setEnabled:YES];
    }

    type = [[entityNamePopUp selectedItem] representedObject];
    entityClass = [type entityClass];
    if (entityClass)
        [reduceModePopUp selectItemWithTitle:[entityClass titleForPopUp]];
}

- (void)calcHierarchy
{
    ReduceEntityType *entityType;
    NSEnumerator *entityTypeEnumerator;
    
    [typesContainingReducedTypes removeAllObjects];

    entityTypeEnumerator = [reduceEntityTypes objectEnumerator];
    while ((entityType = [entityTypeEnumerator nextObject]) != nil) {
        [self addToHierarchy:entityType];
    }

    [super hierarchyChanged];
}

- (void)addToHierarchy:(ReduceEntityType *)entityType
{
    PajeContainerType *containerType;
    NSMutableArray *containedTypes;
    
    containerType = [entityType containerType];
    containedTypes = [typesContainingReducedTypes objectForKey:containerType];
    
    if (containedTypes == nil) {
        containedTypes = [NSMutableArray arrayWithObject:entityType];
        [containedTypes addObjectsFromArray:[super containedTypesForContainerType:containerType]];
        [typesContainingReducedTypes setObject:containedTypes
                                        forKey:containerType];
    } else {
        [containedTypes addObject:entityType];
    }
}

//
// interaction with interface
//
- (IBAction)createEntityType:(id)sender;
{
    ReduceEntityType *selectedEntityType;
    ReduceEntityType *newEntityType;
    NSString *newEntityName;
    int index;

    newEntityName = [entityNameField stringValue];
    index = [entityNamePopUp indexOfItemWithTitle:newEntityName];
    if (index != -1) {
        [entityNamePopUp selectItemAtIndex:index];
        [self entityNamePopUpChanged:self];
        return;
    }

    selectedEntityType = [[entityNamePopUp selectedItem] representedObject];
    if (selectedEntityType) {
        newEntityType = [ReduceEntityType typeWithName:newEntityName
                                         containerType:(PajeContainerType *)[self containerTypeForType:selectedEntityType]
                                             component:self];
        [newEntityType setEntityClass:[selectedEntityType entityClass]];
        [newEntityType setEntityTypeToReduce:[selectedEntityType entityTypeToReduce]];
        [newEntityType addValuesToFilter:[[selectedEntityType filterValues] allObjects]];        
    } else {
        newEntityType = [ReduceEntityType typeWithName:newEntityName
                                         containerType:(PajeContainerType *)[self rootEntityType]
                                             component:self];
        [newEntityType setEntityClass:[CountReduceEntity class]];
        [newEntityType setEntityTypeToReduce:nil]; //FIXME
    }
    [reduceEntityTypes addObject:newEntityType];
    [entityTypesDictionary setObject:[newEntityType dictionaryForDefaults]
                              forKey:[newEntityType description]];
    [self registerDefaults];
    [self addToHierarchy:newEntityType];

    [self calcEntityNamePopUp];
    [entityNamePopUp selectItemWithTitle:[newEntityType description]];
    [self entityNamePopUpChanged:self];
    [super hierarchyChanged];
}

- (IBAction)deleteEntityType:(id)sender
{
    PajeEntityType *entityType;
    entityType = [[entityNamePopUp selectedItem] representedObject];
    if (entityType == nil) {
        NSBeep();
        return;
    }
    [entityTypesDictionary removeObjectForKey:[entityType description]];
    [reduceEntityTypes removeObject:entityType];
    [self calcHierarchy];
    [self registerDefaults];
    [self hierarchyChanged];
}

- (IBAction)renameEntityType:(id)sender
{
    ReduceEntityType *entityType;
    NSString *oldName;
    NSString *newName;
    entityType = [[entityNamePopUp selectedItem] representedObject];
    oldName = [entityType description];
    newName = [entityNameField stringValue];
    if ((oldName == nil) || (newName == nil) || [newName isEqual:oldName]) {
        NSBeep();
        return;
    }
    [reduceEntityTypes removeObject:entityType];
    [entityType setDescription:newName];
    [reduceEntityTypes addObject:entityType];
    [entityTypesDictionary removeObjectForKey:oldName];
    [entityTypesDictionary setObject:[entityType dictionaryForDefaults]
                              forKey:newName];
    [self calcHierarchy];
    [self registerDefaults];
    [[entityNamePopUp selectedItem] setTitle:newName];
    [entityNamePopUp synchronizeTitleAndSelectedItem];
//    [super hierarchyChanged];
}

- (IBAction)entityNamePopUpChanged:(id)sender
{
    [entityNameField setStringValue:[entityNamePopUp titleOfSelectedItem]];
    [self calcEntityTypePopUp];
    [self calcGroupPopUp];
    [self refreshMatrix];
}

- (IBAction)entityTypePopUpChanged:(id)sender
{
    ReduceEntityType *type;
    PajeEntityType *newEntityTypeToReduce;
    
    type = [[entityNamePopUp selectedItem] representedObject];
    if (type == nil) {
        NSBeep();
        return;
    }
    newEntityTypeToReduce = [[entityTypePopUp selectedItem] representedObject];
    if (![[type entityTypeToReduce] isEqual:newEntityTypeToReduce]) {
        [type setEntityTypeToReduce:newEntityTypeToReduce];
        [entityTypesDictionary setObject:[type dictionaryForDefaults]
                                  forKey:[type description]];
        [self registerDefaults];
        [self calcGroupPopUp];
        [self refreshMatrix];
        [self calcHierarchy];
    }
}

- (IBAction)groupByPopUpChanged:(id)sender
{
    ReduceEntityType *type;
    PajeContainerType *newContainerType;

    type = [[entityNamePopUp selectedItem] representedObject];
    if (type == nil) {
        NSBeep();
        return;
    }
    newContainerType = [[groupByPopUp selectedItem] representedObject];
    if (![newContainerType isEqual:[type containerType]]) {
        [type setContainerType:newContainerType];
        [entityTypesDictionary setObject:[type dictionaryForDefaults]
                                  forKey:[type description]];
        [self registerDefaults];
        [self refreshMatrix];
        [self calcHierarchy];
    }
}

- (IBAction)reduceModePopUpChanged:(id)sender
{
    ReduceEntityType *type;
    Class entityClass;

    type = [[entityNamePopUp selectedItem] representedObject];
    if (type == nil) {
        NSBeep();
        return;
    }
    entityClass = [[reduceModePopUp selectedItem] representedObject];
    if (entityClass == nil) {
        NSBeep();
        return;
    }
    [type setEntityClass:entityClass];
    
    [entityTypesDictionary setObject:[type dictionaryForDefaults]
                              forKey:[type description]];
    [self registerDefaults];

    [super dataChangedForEntityType:type];
}

- (IBAction)matrixChanged:(id)sender
// some cell has been (de)selected in matrix.
{
    ReduceEntityType *type;
    NSButtonCell *cell;

    cell = [sender selectedCell];

    if (nil == cell)
        return;

    type = [[entityNamePopUp selectedItem] representedObject];
    if (type == nil) {
        NSBeep();
        return;
    }
    if ([cell state]) {
        [type removeValueFromFilter:[cell representedObject]];
    } else {
        [type addValueToFilter:[cell representedObject]];
    }
    [entityTypesDictionary setObject:[type dictionaryForDefaults]
                              forKey:[type description]];
    [self registerDefaults];

    [super dataChangedForEntityType:type];
}


- (void)refreshMatrix
{
    unsigned i, n;
    NSButtonCell *cell;
    NSArray *allArray;
    ReduceEntityType *type;

    type = [[entityNamePopUp selectedItem] representedObject];
    allArray = [inputComponent allValuesForEntityType:[type entityTypeToReduce]];

    n = [allArray count];
    [nameMatrix renewRows:n columns:1];
    for (i = 0; i < n; i++) {
        NSString *name = [allArray objectAtIndex:i];
        cell = [nameMatrix cellAtRow:i column:0];
        [cell setTitle:name];
        [cell setRepresentedObject:name];
        [cell setState:![[type filterValues] containsObject:name]];
    }
    [nameMatrix sizeToFit];
    [nameMatrix setNeedsDisplay:YES];
}

//
// Trace messages that are filtered
//
- (NSArray *)containedTypesForContainerType:(PajeEntityType *)containerType
{
    NSArray *containedTypes;
    containedTypes = [typesContainingReducedTypes objectForKey:containerType];
    if (containedTypes != nil) {
        return containedTypes;
    } else {
        return [super containedTypesForContainerType:containerType];
    }
}

- (NSEnumerator *)enumeratorOfEntitiesTyped:(PajeEntityType *)entityType
                                inContainer:(PajeContainer *)container
                                   fromTime:(NSDate *)start
                                     toTime:(NSDate *)end
                                minDuration:(double)minDuration
{
    if (![entityType isKindOfClass:[ReduceEntityType class]]) {
        return [super enumeratorOfEntitiesTyped:entityType
                                    inContainer:container
                                       fromTime:start
                                         toTime:end
                                    minDuration:minDuration];
    }

    return [(ReduceEntityType *)entityType
                        enumeratorOfEntitiesInContainer:container
                                               fromTime:start
                                                 toTime:end
                                            minDuration:minDuration];
}

- (NSEnumerator *)enumeratorOfCompleteEntitiesTyped:(PajeEntityType *)entityType
                                        inContainer:(PajeContainer *)container
                                           fromTime:(NSDate *)start
                                             toTime:(NSDate *)end
                                        minDuration:(double)minDuration
{
    if (![entityType isKindOfClass:[ReduceEntityType class]]) {
        return [super enumeratorOfCompleteEntitiesTyped:entityType
                                            inContainer:container
                                               fromTime:start
                                                 toTime:end
                                            minDuration:minDuration];
    }

    return [(ReduceEntityType *)entityType
                        enumeratorOfCompleteEntitiesInContainer:container
                                                       fromTime:start
                                                         toTime:end
                                                    minDuration:minDuration];
}

- (BOOL)canHighlightEntity:(PajeEntity *)entity
{
    if ([entity isKindOfClass:[ReduceEntity class]]) {
        return NO;
    } else {
        return [inputComponent canHighlightEntity:entity];
    }
}

- (PajeDrawingType)drawingTypeForEntityType:(PajeEntityType *)entityType
{
    if ([entityType isKindOfClass:[ReduceEntityType class]])
        return [(ReduceEntityType *)entityType drawingType];
    else
        return [super drawingTypeForEntityType:entityType];
}

- (double)doubleValueForEntity:(PajeEntity *)entity
{
    if ([entity isKindOfClass:[ReduceEntity class]]) {
        return [(ReduceEntity *)entity doubleValue];
    } else {
        return [inputComponent doubleValueForEntity:entity];
    }
}

- (double)minValueForEntity:(PajeEntity *)entity
{
    if ([entity isKindOfClass:[ReduceEntity class]]) {
        return [(ReduceEntity *)entity minValue];
    } else {
        return [inputComponent minValueForEntity:entity];
    }
}

- (double)maxValueForEntity:(PajeEntity *)entity
{
    if ([entity isKindOfClass:[ReduceEntity class]]) {
        return [(ReduceEntity *)entity maxValue];
    } else {
        return [inputComponent maxValueForEntity:entity];
    }
}

- (double)minValueForEntityType:(PajeEntityType *)entityType
{
    if ([entityType isKindOfClass:[ReduceEntityType class]]) {
        return [(ReduceEntityType *)entityType minValue];
    } else {
        return [super minValueForEntityType:entityType];
    }
}

- (double)maxValueForEntityType:(PajeEntityType *)entityType
{
    if ([entityType isKindOfClass:[ReduceEntityType class]]) {
        return [(ReduceEntityType *)entityType maxValue];
    } else {
        return [super maxValueForEntityType:entityType];
    }
}

- (double)minValueForEntityType:(PajeEntityType *)entityType
                    inContainer:(PajeContainer *)container
{
    if ([entityType isKindOfClass:[ReduceEntityType class]]) {
        return [(ReduceEntityType *)entityType minValue];
    } else {
        return [super minValueForEntityType:entityType inContainer:container];
    }
}

- (double)maxValueForEntityType:(PajeEntityType *)entityType
                    inContainer:(PajeContainer *)container
{
    if ([entityType isKindOfClass:[ReduceEntityType class]]) {
        return [(ReduceEntityType *)entityType maxValue];
    } else {
        return [super maxValueForEntityType:entityType inContainer:container];
    }
}

- (id)configuration
{
    NSEnumerator *typeEnum;
    ReduceEntityType *type;
    NSMutableArray *types;
    
    types = [NSMutableArray arrayWithCapacity:[reduceEntityTypes count]];
    typeEnum = [reduceEntityTypes objectEnumerator];
    while ((type = [typeEnum nextObject]) != nil) {
        [types addObject:[type dictionaryForDefaults]];
    }
    return types;
}

- (void)setConfiguration:(id)config
{
    NSEnumerator *filterEnum;
    NSDictionary *filter;
    ReduceEntityType *entityType;

    [reduceEntityTypes removeAllObjects];
    filterEnum = [config objectEnumerator];
    while ((filter = [filterEnum nextObject]) != nil) {
        entityType = [ReduceEntityType typeFromDictionary:filter component:self];
        if (entityType != nil) {
            [reduceEntityTypes addObject:entityType];
            [self addToHierarchy:entityType];
        }
    }

    [self calcEntityNamePopUp];
    [self calcEntityTypePopUp];
    [self calcGroupPopUp];
    [self calcReduceModePopUp];
    [self refreshMatrix];
    [self calcHierarchy];

    //[super hierarchyChanged];
}

@end