Revision 146

View differences:

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/LayoutNotification.java
37 37
    
38 38
    /** Fired when the layout doesn't have to be repainted */
39 39
    public static final String LAYOUT_REFRESH = "layout_refresh";
40
    
41
    public static final String FRAME_ADDED = "frame_added";
42
    public static final String FRAME_ADDING = "frame_adding";
43
    public static final String FRAME_REMOVING = "frame_removed";
44
    public static final String FRAME_REMOVED = "frame_removed";
45 40
      
46 41
    /**
47 42
     * Returns the type of this notification, represented by one of the constants defined in this interface.
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
137 137

  
138 138
            if (fframe.isSelected()) {
139 139
                observers.notifyObservers(this, 
140
                        new DefaultLayoutNotification(LayoutNotification.FRAME_REMOVING));
140
                        new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVING, fframe));
141 141
                fframe.setSelected(false);
142 142
                fcr.delete(fframe);
143 143
                observers.notifyObservers(this, 
144
                        new DefaultLayoutNotification(LayoutNotification.FRAME_REMOVED));
144
                        new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVED, fframe));
145 145
            }
146 146
        }
147 147
        fcr.endComplex();
......
164 164

  
165 165
    public void delFFrame(IFFrame frame) {
166 166
        observers.notifyObservers(this, 
167
                new DefaultLayoutNotification(LayoutNotification.FRAME_REMOVING));
167
                new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVING, frame));
168 168
        for (int i = 0; i < fcr.getFrameManager().getAllFFrames().length; i++) {
169 169
            if (fcr.getFrameManager().getFFrame(i).equals(frame)) {
170 170
            	frame.setSelected(false);
......
173 173
        }
174 174
        updateFFrames();
175 175
        observers.notifyObservers(this, 
176
                new DefaultLayoutNotification(LayoutNotification.FRAME_REMOVED));
176
                new FrameChangedNotification(FrameChangedNotification.FRAME_REMOVED, frame));
177 177
    }
178 178

  
179 179
    public FrameCommandsRecord getFrameCommandsRecord() {
......
183 183
    public void addFFrame(IFFrame frame, boolean clearSelection, boolean select) {
184 184
    	this.addObserver(frame);
185 185
        observers.notifyObservers(this, 
186
                new DefaultLayoutNotification(LayoutNotification.FRAME_ADDING)); 
186
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDING, frame)); 
187 187
        IFFrame[] fframes = getFFrames();
188 188
        if (clearSelection) {
189 189
            for (int i = fframes.length - 1; i >= 0; i--) {
......
207 207
        frame.setLevel(getNumBefore());
208 208
        updateFFrames();
209 209
        observers.notifyObservers(this, 
210
                new DefaultLayoutNotification(LayoutNotification.FRAME_ADDED));
210
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDED, frame));
211 211
    }
212 212

  
213 213
    public void addFFrameSameProperties(IFFrame frame) {
214 214
    	this.addObserver(frame);
215 215
        observers.notifyObservers(this, 
216
                new DefaultLayoutNotification(LayoutNotification.FRAME_ADDING)); 
216
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDING, frame)); 
217 217
        fcr.insert(frame);
218 218
        frame.setSelected(true);
219 219
        frame.setLevel(getNumBefore());
220 220
        updateFFrames();
221 221
        observers.notifyObservers(this, 
222
                new DefaultLayoutNotification(LayoutNotification.FRAME_ADDED));
222
                new FrameChangedNotification(FrameChangedNotification.FRAME_ADDED, frame));
223 223
    }
224 224

  
225 225
    public int getNumBehind() {
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/fframes/FFrame.java
38 38
import org.gvsig.app.project.documents.layout.Attributes;
39 39
import org.gvsig.app.project.documents.layout.DefaultLayoutManager;
40 40
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
41
import org.gvsig.app.project.documents.layout.FrameChangedNotification;
41 42
import org.gvsig.app.project.documents.layout.LayoutContext;
42 43
import org.gvsig.app.project.documents.layout.LayoutControl;
43 44
import org.gvsig.app.project.documents.layout.LayoutManager;
......
848 849
	
849 850
	public void update(Observable observable, Object notification) {
850 851
		if ((notification != null) && (notification instanceof LayoutNotification)){
851
			LayoutNotification layoutNotification = (LayoutNotification)notification;
852
			if (LayoutNotification.FRAME_ADDED.equals(layoutNotification.getType())){
852
			FrameChangedNotification layoutNotification = (FrameChangedNotification)notification;
853
			if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_ADDED.equals(layoutNotification.getType())){
853 854
				afterAdded();
854
			}else if (LayoutNotification.FRAME_ADDING.equals(layoutNotification.getType())){
855
			}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_ADDING.equals(layoutNotification.getType())){
855 856
				beforeAdded();
856
			}else if (LayoutNotification.FRAME_REMOVING.equals(layoutNotification.getType())){
857
			}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_REMOVING.equals(layoutNotification.getType())){
857 858
				beforeRemoved();
858
			}else if (LayoutNotification.FRAME_REMOVED.equals(layoutNotification.getType())){
859
			}else if (this.equals(layoutNotification.getFrame()) && FrameChangedNotification.FRAME_REMOVED.equals(layoutNotification.getType())){
859 860
				afterRemoved();
860 861
			}
861 862
		}
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/fframes/FFrameView.java
54 54
import org.gvsig.fmap.mapcontext.MapContext;
55 55
import org.gvsig.fmap.mapcontext.MapContextException;
56 56
import org.gvsig.fmap.mapcontext.ViewPort;
57
import org.gvsig.fmap.mapcontext.events.AtomicEvent;
57 58
import org.gvsig.fmap.mapcontext.events.ColorEvent;
58 59
import org.gvsig.fmap.mapcontext.events.ExtentEvent;
59 60
import org.gvsig.fmap.mapcontext.events.ProjectionEvent;
61
import org.gvsig.fmap.mapcontext.events.listeners.AtomicEventListener;
60 62
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener;
61 63
import org.gvsig.fmap.mapcontext.layers.CancelationException;
62 64
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
......
636 638
    public void updateScaleCtrl() {
637 639
    	NewStatusBar statusbar = PluginServices.getMainFrame().getStatusBar();
638 640
    	MapContext mapContext = this.getMapContext();
641
    	if (mapContext==null) {
642
    		return;
643
    	}
639 644
    	statusbar.setMessage("units",
640 645
    			PluginServices.getText(this, mapContext.getDistanceName()));
641 646
    	statusbar.setControlValue("layout-view-change-scale",
......
792 797
    }
793 798
    
794 799
    protected void removeToc() {
795
    	this.toc = null;
796
    	this.getLayoutPanel().removeLateralComponent();
800
    	if (this.getLayoutPanel()!=null && this.toc!=null) {
801
    		this.getLayoutPanel().removeLateralComponent(this.toc);
802
    		this.toc = null;
803
    	}
797 804
    }
798 805

  
799 806
    @Override
......
846 853
	protected void invalidateLayout() {
847 854
		b_validCache = false;
848 855
        observers.notifyObservers(this, 
849
                new DefaultLayoutNotification(LayoutNotification.LAYOUT_INVALIDATED));
856
                new DefaultLayoutNotification(LayoutNotification.LAYOUT_REFRESH));
850 857
	}
851 858

  
852 859
	public void refresh() {
......
869 876
    		if (linked) {
870 877
    			getView().getMapContext().addLayerListener(viewDocListener);
871 878
    			getView().getMapContext().getLayers().addLayerCollectionListener(viewDocListener);
879
    			getView().getMapContext().addAtomicEventListener(viewDocListener);
872 880
    		}
873 881
    		if (getTypeScale()==IFFrameUseFMap.AUTOMATICO) {
874 882
    			getView().getMapContext().getViewPort().addViewPortListener(viewDocListener);
......
920 928
		if (this.getView()!=null && this.getView().getMapContext()!=null) {
921 929
			clearViewListeners(this.getView().getMapContext());
922 930
		}
923
		if (b_hasToc && this.getLayoutPanel()!=null) {
924
			this.getLayoutPanel().removeLateralComponent();
931
		if (b_hasToc) {
932
			removeToc();
925 933
		}
926 934
	}
927 935

  
......
949 957
	protected void doSetSelected(int selectedStatus) {
950 958
		super.doSetSelected(selectedStatus);
951 959
		addToc();
960
		updateScaleCtrl();
952 961
	}
953 962

  
954 963
	private class ViewDocListener
955
	implements ViewPortListener, LegendListener, LayerCollectionListener {
964
	implements ViewPortListener, LegendListener, LayerCollectionListener, AtomicEventListener {
956 965

  
957 966
		public void extentChanged(ExtentEvent e) {
958 967
			if (!b_fframeOriginatedUpdate && getTypeScale()==AUTOMATICO) {
......
1036 1045
				throws CancelationException {
1037 1046
			conditionalRedraw();
1038 1047
		}
1048

  
1049
		public void atomicEvent(AtomicEvent e) {
1050
			conditionalRedraw();
1051
			// TODO Auto-generated method stub
1052
			
1053
		}
1039 1054
	}
1040 1055

  
1041 1056
	private class OwnMapContextListener
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/gui/LayoutPanel.java
146 146
	
147 147
	public abstract void addLateralComponent(JComponent c);
148 148
	
149
	public abstract void removeLateralComponent();
149
	public abstract void removeLateralComponent(JComponent c);
150 150
	
151 151
	public abstract void hideLateralComponent(JComponent c);
152 152

  
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/gui/DefaultLayoutPanel.java
559 559
		leftPanel.add(c, BorderLayout.CENTER);
560 560
	}
561 561
	
562
	public void removeLateralComponent() {
562
	public void removeLateralComponent(JComponent c) {
563 563
		if (leftPanel.getComponentCount()>0) {
564
			leftPanel.remove(0);
564
			leftPanel.remove(c);
565 565
		}
566 566
	}
567 567
	
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/FrameChangedNotification.java
1
package org.gvsig.app.project.documents.layout;
2

  
3
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
4

  
5
public class FrameChangedNotification extends DefaultLayoutNotification {
6
    public static final String FRAME_ADDED = "frame_added";
7
    public static final String FRAME_ADDING = "frame_adding";
8
    public static final String FRAME_REMOVING = "frame_removed";
9
    public static final String FRAME_REMOVED = "frame_removed";
10
	private IFFrame frame;
11

  
12
	public FrameChangedNotification(String type, IFFrame frame) {
13
		super(type);
14
		this.frame = frame;
15
	}
16
	
17
	public IFFrame getFrame() {
18
		return this.frame;
19
	}
20

  
21
}

Also available in: Unified diff