Revision 250 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/listener/LayoutAddRectangleWithDialogListener.java

View differences:

LayoutAddRectangleWithDialogListener.java
27 27
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
28 28
import org.gvsig.app.project.documents.layout.LayoutDocument;
29 29
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
30
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification;
30 31
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
31 32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32 33
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
33 34
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
35
import org.gvsig.tools.observer.Observable;
36
import org.gvsig.tools.observer.Observer;
34 37

  
35 38
/**
36 39
 * @author gvSIG Team
......
56 59
        r = getRectangle(TOLERANCE);
57 60
        fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layoutPanel
58 61
            .getLayoutControl().getAT()));
59
        IFFrameDialog fframedialog =
62
        final IFFrameDialog fframedialog =
60 63
            layoutManager.createFFrameDialog(fframe, layoutPanel);
61 64
        if (fframedialog != null) {
65
        	fframedialog.addObserver(new Observer() {
66
				public void update(Observable observable, Object notification) {
67
					if (notification instanceof FFrameDialogNotification &&
68
							((FFrameDialogNotification) notification).getType()==FFrameDialogNotification.DIALOG_CLOSED) {
69
				        IFFrame newFrame = fframedialog.getFFrame();
70
				        if (newFrame != null) {
71
				            layoutPanel.getLayoutContext().addFFrame(newFrame, true, true);
72
				        }
73
				        PluginServices.getMainFrame().enableControls();
74
				        layoutPanel.getLayoutControl().refresh();
75
					}
76
				}
77
			});
62 78
            PluginServices.getMDIManager().addWindow(fframedialog);
63 79
        }
64

  
65
        IFFrame newFrame = fframedialog.getFFrame();
66
        if (newFrame != null) {
67
            layoutPanel.getLayoutContext().addFFrame(newFrame, true, true);
68
        }
69
        PluginServices.getMainFrame().enableControls();
70
        layoutPanel.getLayoutControl().refresh();
71 80
    }
72 81

  
73 82
    public abstract String getFFrameName();

Also available in: Unified diff