2282 |
2282 |
2283 addSpec:aSpecification builder:aBuilder in:aFrame |
2283 addSpec:aSpecification builder:aBuilder in:aFrame |
2284 "build view and subviews from aSpecification into a frame. The top view |
2284 "build view and subviews from aSpecification into a frame. The top view |
2285 is returned. The contained components of a spec are set to nil |
2285 is returned. The contained components of a spec are set to nil |
2286 " |
2286 " |
2287 |cls| |
2287 ^ self addSpec:aSpecification builder:aBuilder in:aFrame beforeIndex:nil. |
|
2288 ! |
|
2289 |
|
2290 addSpec:aSpecification builder:aBuilder in:aFrame beforeIndex:anIndexOrNil |
|
2291 "build view and subviews from aSpecification into a frame. The top view |
|
2292 is returned. The contained components of a spec are set to nil |
|
2293 " |
|
2294 |cls newView viewPosition subviewToRealize| |
2288 |
2295 |
2289 cls := self resolveName:className. |
2296 cls := self resolveName:className. |
2290 |
2297 |
2291 cls notNil ifTrue:[ |
2298 cls notNil ifTrue:[ |
2292 aBuilder applicationClass:cls. |
2299 aBuilder applicationClass:cls. |
2293 ]. |
2300 ]. |
2294 |
2301 |
|
2302 ( anIndexOrNil notNil |
|
2303 and:[anIndexOrNil between:1 and:(aFrame subViews size)] |
|
2304 ) ifTrue:[ |
|
2305 viewPosition := anIndexOrNil. |
|
2306 ]. |
|
2307 |
2295 "/ remember view<->spec associations to tree |
2308 "/ remember view<->spec associations to tree |
2296 aBuilder componentCreationHook:[:aView :aSpec :builder| |
2309 aBuilder componentCreationHook:[:aView :aSpec :builder| |
2297 |newProperty copyOfSpec nameOfSpec| |
2310 |newProperty copyOfSpec nameOfSpec beforeIndex| |
|
2311 |
|
2312 (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[ |
|
2313 subviewToRealize := aFrame. |
|
2314 |
|
2315 [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[ |
|
2316 subviewToRealize := subviewToRealize superView. |
|
2317 ]. |
|
2318 subviewToRealize notNil ifTrue:[ |
|
2319 beforeIndex := viewPosition. |
|
2320 aFrame changeSequenceOrderFor:subviewToRealize to:viewPosition. |
|
2321 ]. |
|
2322 ]. |
2298 |
2323 |
2299 newProperty := ViewProperty new. |
2324 newProperty := ViewProperty new. |
2300 copyOfSpec := aSpec copy. |
2325 copyOfSpec := aSpec copy. |
2301 newProperty spec:copyOfSpec. |
2326 newProperty spec:copyOfSpec. |
2302 newProperty view:aView. |
2327 newProperty view:aView. |
2310 nameOfSpec := copyOfSpec name. |
2335 nameOfSpec := copyOfSpec name. |
2311 |
2336 |
2312 (nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[ |
2337 (nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[ |
2313 copyOfSpec name:(self uniqueNameFor:copyOfSpec) |
2338 copyOfSpec name:(self uniqueNameFor:copyOfSpec) |
2314 ]. |
2339 ]. |
2315 treeView addProperty:newProperty. |
2340 treeView addProperty:newProperty beforeIndex:beforeIndex. |
2316 ]. |
2341 ]. |
2317 ^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
2342 newView := aSpecification buildViewWithLayoutFor:aBuilder in:aFrame. |
|
2343 |
|
2344 subviewToRealize notNil ifTrue:[ |
|
2345 subviewToRealize realize. |
|
2346 |
|
2347 aFrame subViews from:(viewPosition + 1 ) do:[:v| |
|
2348 v shown ifTrue:[v raise] |
|
2349 ]. |
|
2350 ]. |
|
2351 ^ newView |
2318 |
2352 |
2319 "Modified: 4.7.1997 / 23:48:55 / cg" |
2353 "Modified: 4.7.1997 / 23:48:55 / cg" |
2320 ! |
2354 ! |
2321 |
2355 |
2322 fullSpecFor:aView |
2356 fullSpecFor:aView |
2611 ! |
2645 ! |
2612 |
2646 |
2613 createUndoRemove:aView |
2647 createUndoRemove:aView |
2614 "create undo method before deleting views |
2648 "create undo method before deleting views |
2615 " |
2649 " |
2616 |prop pid| |
2650 |item itemParent prop args| |
2617 |
2651 |
2618 (prop := self propertyOfView:aView) notNil ifTrue:[ |
2652 item := treeView detectItemCorespondingToView:aView. |
2619 (pid := self propertyOfParentForView:aView) notNil ifTrue:[ |
2653 item isNil ifTrue:[^ self ]. |
2620 pid := pid identifier |
2654 |
2621 ]. |
2655 itemParent := item parent. |
2622 |
2656 itemParent isNil ifTrue:[^ self ]. |
2623 undoHistory addUndoSelector:#undoRemove: |
2657 |
2624 withArgs:(Array with:(self fullSpecFor:aView) |
2658 prop := item contents. |
2625 with:(prop identifier) |
2659 |
2626 with:pid). |
2660 args := Array |
2627 self undoHistoryChanged. |
2661 with:(self fullSpecFor:aView) |
2628 ] |
2662 with:(prop identifier) |
|
2663 with:(itemParent contents identifier) |
|
2664 with:(itemParent indexOfChild:item). |
|
2665 |
|
2666 |
|
2667 undoHistory addUndoSelector:#'undoRemove:' withArgs:args. |
|
2668 self undoHistoryChanged. |
2629 ! |
2669 ! |
2630 |
2670 |
2631 createUndoSpecModify:aProp |
2671 createUndoSpecModify:aProp |
2632 "undo method when changing the specification for an object |
2672 "undo method when changing the specification for an object |
2633 " |
2673 " |
2662 ! |
2702 ! |
2663 |
2703 |
2664 undoRemove:args |
2704 undoRemove:args |
2665 "undo method when removing an object; see 'createUndoRemove:' |
2705 "undo method when removing an object; see 'createUndoRemove:' |
2666 " |
2706 " |
2667 |frame prop view| |
2707 |frame prop view position parentId| |
2668 |
2708 |
2669 (args at:3) notNil ifTrue:[ |
2709 position := args at:4 ifAbsent:nil. |
2670 frame := self findViewWithId:(args at:3). |
2710 parentId := args at:3 ifAbsent:nil. |
2671 ]. |
2711 |
2672 frame isNil ifTrue:[ |
2712 parentId notNil ifTrue:[ |
2673 frame := self |
2713 frame := self findViewWithId:parentId. |
2674 ]. |
2714 ]. |
2675 view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame. |
2715 |
|
2716 frame isNil ifTrue:[ frame := self. ]. |
|
2717 |
|
2718 view := self addSpec:(args at:1) |
|
2719 builder:(UIBuilder new isEditing:true) |
|
2720 in:frame |
|
2721 beforeIndex:position. |
|
2722 |
2676 view realize. |
2723 view realize. |
2677 |
|
2678 prop := self propertyOfView:view. |
2724 prop := self propertyOfView:view. |
2679 prop identifier:(args at:2). |
2725 prop identifier:(args at:2). |
2680 ! |
2726 ! |
2681 |
2727 |
2682 undoSpecModify:args |
2728 undoSpecModify:args |