Revision 147 branches/usability_v2/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/DefaultLayoutContext.java

View differences:

DefaultLayoutContext.java
34 34
import org.gvsig.app.project.documents.layout.fframes.FFrameGroup;
35 35
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
36 36
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
37
import org.gvsig.app.project.documents.layout.toc.TocModelObserver;
38
import org.gvsig.fmap.mapcontext.MapContext;
37 39
import org.gvsig.tools.ToolsLocator;
38 40
import org.gvsig.tools.dynobject.DynStruct;
39 41
import org.gvsig.tools.observer.ObservableHelper;
......
78 80
    private AffineTransform m_MatrizTransf;
79 81
    
80 82
    private ObservableHelper observers;
83
    private CustomizableObserverHelper tocObservers = new CustomizableObserverHelper() {
84
		
85
		@Override
86
		protected void doNotify(Object listener, Object data) {
87
			TocModelObserver l = (TocModelObserver) listener;
88
			l.tocUpdated(DefaultLayoutContext.this, (TocModelChangedNotification) data);
89
		}
90
	};
91

  
92
	private MapContext tocModel = null;
81 93
    
82 94
    /**
83 95
     * Create a new object of LayoutContext.
......
137 149

  
138 150
            if (fframe.isSelected()) {
139 151
                observers.notifyObservers(this, 
140
                        new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVING, fframe));
152
                        new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVING, fframe));
141 153
                fframe.setSelected(false);
142 154
                fcr.delete(fframe);
143 155
                observers.notifyObservers(this, 
144
                        new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVED, fframe));
156
                        new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVED, fframe));
145 157
            }
146 158
        }
147 159
        fcr.endComplex();
......
164 176

  
165 177
    public void delFFrame(IFFrame frame) {
166 178
        observers.notifyObservers(this, 
167
                new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVING, frame));
179
                new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVING, frame));
168 180
        for (int i = 0; i < fcr.getFrameManager().getAllFFrames().length; i++) {
169 181
            if (fcr.getFrameManager().getFFrame(i).equals(frame)) {
170 182
            	frame.setSelected(false);
......
173 185
        }
174 186
        updateFFrames();
175 187
        observers.notifyObservers(this, 
176
                new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVED, frame));
188
                new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_REMOVED, frame));
177 189
    }
178 190

  
179 191
    public FrameCommandsRecord getFrameCommandsRecord() {
......
183 195
    public void addFFrame(IFFrame frame, boolean clearSelection, boolean select) {
184 196
    	this.addObserver(frame);
185 197
        observers.notifyObservers(this, 
186
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDING, frame)); 
198
                new FrameChangedNotificationImpl(FrameChangedNotification.FRAME_ADDING, frame)); 
187 199
        IFFrame[] fframes = getFFrames();
188 200
        if (clearSelection) {
189 201
            for (int i = fframes.length - 1; i >= 0; i--) {
......
207 219
        frame.setLevel(getNumBefore());
208 220
        updateFFrames();
209 221
        observers.notifyObservers(this, 
210
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDED, frame));
222
                new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_ADDED, frame));
211 223
    }
212 224

  
213 225
    public void addFFrameSameProperties(IFFrame frame) {
214 226
    	this.addObserver(frame);
215 227
        observers.notifyObservers(this, 
216
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDING, frame)); 
228
                new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_ADDING, frame)); 
217 229
        fcr.insert(frame);
218 230
        frame.setSelected(true);
219 231
        frame.setLevel(getNumBefore());
220 232
        updateFFrames();
221 233
        observers.notifyObservers(this, 
222
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDED, frame));
234
                new FrameChangedNotificationImpl(FrameChangedNotificationImpl.FRAME_ADDED, frame));
223 235
    }
224 236

  
225 237
    public int getNumBehind() {
......
342 354
    
343 355
    public void notifAllObservers(){
344 356
        observers.notifyObservers(this, 
345
            new DefaultLayoutNotification(LayoutNotification.LAYOUT_REFRESH)); 
357
            new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
346 358
    }
347 359

  
348 360
    public static void registerPersistent() {
......
424 436
    public void deleteObservers() {
425 437
       observers.deleteObservers();        
426 438
    }
439

  
440
	public void setTocModel(MapContext tocModel) {
441
		MapContext oldModel = this.tocModel;
442
		this.tocModel = tocModel;
443
		if (tocModel==oldModel){
444
			// no real change
445
			return;
446
		}
447
		else {
448
	    	tocObservers.notifyObservers(this, 
449
	                new TocModelChangedImpl(TocModelChangedNotification.MODEL_SET, tocModel));			
450
		}
451
	}
452
	
453
	public void notifyTocUpdated() {
454
    	tocObservers.notifyObservers(this, 
455
                new TocModelChangedImpl(TocModelChangedNotification.MODEL_CHANGED, tocModel));			
456
		
457
	}
458

  
459
	public MapContext getTocModel() {
460
		return this.tocModel;
461
	}
462

  
463
	public void addTocObserver(TocModelObserver observer) {
464
		this.tocObservers.addObserver(observer);
465
	}
466

  
467
	public void removeTocObserver(TocModelObserver observer) {
468
		this.tocObservers.deleteObserver(observer);
469
	}
470

  
471
	public void removeTocObservers() {
472
		this.tocObservers.deleteObservers();		
473
	}
427 474
}

Also available in: Unified diff