Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / gui / LayoutPanelImpl.java @ 1633

History | View | Annotate | Download (2.92 KB)

1
package org.gvsig.app.project.documents.layout.gui;
2

    
3
import java.awt.GridBagConstraints;
4
import java.awt.event.ActionEvent;
5
import java.awt.event.ActionListener;
6
import java.util.Collections;
7

    
8
import org.gvsig.andami.PluginsLocator;
9
import org.gvsig.app.ApplicationLocator;
10
import org.gvsig.app.gui.preferencespage.PreferenceKeys;
11
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog;
12
import org.gvsig.tools.ToolsLocator;
13
import org.gvsig.tools.i18n.I18nManager;
14
import org.gvsig.tools.swing.api.ToolsSwingLocator;
15
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
16
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
17
import org.gvsig.utils.XMLEntity;
18

    
19
/**
20
 * Layout document window. This class contain the specific behaviour of the layout window
21
 * that is not suitable for other documents extending LayoutDocument (such as the
22
 * mapsheets plugin).
23
 * 
24
 * If you need to extend a generic layout window in your document, extend
25
 * LayoutPanel or DefauLayoutPanel instead of this class.
26
 *
27
 * @author Cesar Martinez Izquierdo
28
 *
29
 */
30
public class LayoutPanelImpl extends DefaultLayoutPanel {
31
    protected boolean isInitConfigDialogEnabled() {
32
            XMLEntity entity = PluginsLocator.getManager().getPlugin(this).getPersistentXML();
33
            if (entity.contains(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME)) {
34
                    return entity.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME);
35
            }
36
            else {
37
                    return PreferenceKeys.FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT;
38
            }
39
    }
40

    
41
    
42
    protected void onInitialConfigCanceled() {
43
            if (layoutDocument!=null) {
44
                    ApplicationLocator.getManager().getUIManager().closeWindow(this);
45
                    ApplicationLocator.getProjectManager().getCurrentProject().removeDocument(layoutDocument);
46
            }
47
    }
48
        
49
    /**
50
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
51
     */
52
    public void windowActivated() {
53
        if (getLayoutContext() != null && !getLayoutContext().hasDocBeenOpened()) {
54
            getLayoutContext().setHasDocBeenOpened(true);
55
            if (isInitConfigDialogEnabled()) {
56
                FConfigLayoutDialog configDialog = new FConfigLayoutDialog(this, true);
57
                I18nManager i18n = ToolsLocator.getI18nManager();
58
                ((WindowManager_v2) ToolsSwingLocator.getWindowManager()).showWindow(
59
                        configDialog,
60
                        i18n.getTranslation("Preparar_pagina"),
61
                        WindowManager.MODE.WINDOW,
62
                        Collections.singletonMap("align", GridBagConstraints.CENTER)
63
                );
64
                configDialog.addCancelButtonActionListener(new ActionListener() {
65

    
66
                    public void actionPerformed(ActionEvent e) {
67
                        LayoutPanelImpl.this.onInitialConfigCanceled();
68
                    }
69

    
70
                });
71
            }
72

    
73
        }
74
        super.windowActivated();
75
    }
76

    
77
}