Revision 1652

View differences:

tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties
1
#Mon Oct 09 22:05:45 CEST 2023
2
buildNumber=311
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewZoomPrev.java
1
package org.gvsig.app.extension;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.PluginServices;
5
import org.gvsig.andami.plugins.Extension;
6
import org.gvsig.andami.ui.mdiManager.IWindow;
7
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
8
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
9
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
10
import org.gvsig.fmap.mapcontext.ExtentHistory;
11
import org.gvsig.fmap.mapcontext.MapContext;
12
import org.gvsig.fmap.mapcontext.ViewPort;
13

  
14

  
15

  
16
public class FFrameViewZoomPrev extends Extension {
17

  
18
    public void postInitialize() {
19
    }
20

  
21
    public void initialize() {
22
        IconThemeHelper.registerIcon("action", "layout-view-navigation-zoom-back", this);
23
    }
24

  
25
    
26
    public boolean isEnabled() {
27
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
28
    	if (window instanceof LayoutPanel) {
29
    		LayoutPanel l =
30
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
31
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
32
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
33
    			IFFrameUseFMap fframeView = (IFFrameUseFMap) fframes[0];
34
    			MapContext mc = fframeView.getMapContext();
35
    			if (mc!=null) {
36
    				ExtentHistory history = mc.getViewPort().getEnvelopes();
37
    				if (history.hasPrevious()&&fframeView.getScaleType()==IFFrameUseFMap.SCALE_TYPE.NORMAL) {
38
    					return true;
39
    				}
40
    			}
41
    		}
42
    	}
43
    	return false;
44
    }
45

  
46
    /**
47
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
48
     */
49
    public boolean isVisible() {
50
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
51

  
52
        if (f == null || !(f instanceof LayoutPanel)) {
53
            return false;
54
        }
55
        return true;
56
    }
57

  
58
    public void execute(String arg0) {
59
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
60

  
61
        if (f == null || !(f instanceof LayoutPanel)) {
62
            return;
63
        }
64
		LayoutPanel l =
65
				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
66
   		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
67
		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView)) {
68
			IFFrameUseFMap fframeView = (IFFrameUseFMap) fframes[0];
69
			ViewPort vp = fframeView.getMapContext().getViewPort();
70
	        vp.setPreviousEnvelope();
71
	        l.getDocument().setModified(true);
72
		}
73
    }
74

  
75
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameViewAddLayerExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.PluginsLocator;
26
import org.gvsig.andami.PluginsManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
30
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
/**
36
 * Extension to control the options that can be done on a view added to layout
37
 * 
38
 * @author Cesar Martinez Izquierdo
39
 */
40
public class FFrameViewAddLayerExtension extends Extension {
41

  
42
    private static Logger logger = LoggerFactory.getLogger(FFrameViewAddLayerExtension.class);
43
    //.info("Can't change scale of view.", ex);
44

  
45
    /**
46
     * @see org.gvsig.andami.plugins.IExtension#initialize()
47
     */
48
    public void initialize() {
49
    	
50
    }
51
    
52
    /**
53
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
54
     */
55
    public void execute(String s) {
56
        LayoutPanel layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
57
    	if (s.compareTo("layout-view-add-layer") == 0) {
58
        	PluginsManager manager = PluginsLocator.getManager();
59
        	AddLayer plugin = (AddLayer) manager.getExtension(AddLayer.class);
60
        	IFFrameUseFMap[] fframes = layout.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
61
        	if (fframes.length>0) {
62
        		if (fframes[0].getMapContext()!=null) {
63
        			plugin.addLayers(fframes[0].getMapContext());
64
        			fframes[0].refresh();
65
        			layout.getDocument().setModified(true);
66
        		}
67
        	}
68
        }
69
    }
70
    
71

  
72
    /**
73
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
74
     */
75
    public boolean isEnabled() {
76
    	IWindow window = PluginServices.getMDIManager().getActiveWindow();
77
    	if (window instanceof LayoutPanel) {
78
    		LayoutPanel l =
79
    				(LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
80
    		if (!l.getLayoutContext().isEditable()) {
81
    			return false;
82
    		}
83
    		IFFrameUseFMap[] fframes = l.getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class);
84
    		if (fframes.length==1 && !(fframes[0] instanceof FFrameOverView) && ((IFFrameUseFMap)fframes[0]).getMapContext()!=null) {
85
    			return true;
86
    		}
87
    	}
88
    	return false;
89
    }
90

  
91
    /**
92
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
93
     */
94
    public boolean isVisible() {
95
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
96

  
97
        if (f == null) {
98
            return false;
99
        }
100

  
101
        if (f instanceof LayoutPanel) {
102
            return true;
103
        } else {
104
            return false;
105
        }
106
    }
107
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutGraphicControls.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.app.project.documents.layout.FLayoutGraphics;
31
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33
import org.gvsig.tools.observer.Observable;
34
import org.gvsig.tools.observer.Observer;
35

  
36
/**
37
 * Extensi?n que actua sobre el Layout para controlas las diferentes
38
 * operaciones sobre los gr?ficos.
39
 * 
40
 * @author Vicente Caballero Navarro
41
 */
42
public class LayoutGraphicControls extends Extension {
43

  
44
    private static final Logger logger = LoggerFactory
45
        .getLogger(LayoutGraphicControls.class);
46
    private LayoutPanel layout = null;
47

  
48
    /**
49
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
50
     */
51
    public void execute(String s) {
52
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
53
        FLayoutGraphics lg = new FLayoutGraphics(layout);
54
        logger.debug("Comand : " + s);
55

  
56
        if (s.compareTo("layout-graphic-group") == 0) {
57
            layout.getLayoutContext().getFrameCommandsRecord()
58
                .startComplex(PluginServices.getText(this, "group"));
59
            lg.grouping();
60
            layout.getLayoutContext().getFrameCommandsRecord().endComplex();
61
            layout.getDocument().setModified(true);
62
        } else
63
            if (s.compareTo("layout-graphic-ungroup") == 0) {
64
                lg.ungrouping();
65
                layout.getDocument().setModified(true);
66
            } else
67
                if (s.compareTo("layout-graphic-properties") == 0) {
68
                	lg.openFrameDialog(new Observer() {
69
						public void update(Observable observable,
70
								Object notification) {
71
							if (notification instanceof FFrameDialogNotification &&
72
									((FFrameDialogNotification)notification).getType()==FFrameDialogNotification.FRAME_CREATED) {
73
								getLayout().getDocument().setModified(true);
74
							}
75
						}
76
                	});
77
                } else
78
                    if (s.compareTo("layout-graphic-align") == 0) {
79
                        lg.aligning();
80
                        layout.getDocument().setModified(true);
81
                    } else
82
                        if (s.compareTo("layout-graphic-send-back") == 0) {
83
                            lg.behind();
84
                            layout.getDocument().setModified(true);
85
                        } else
86
                            if (s.compareTo("layout-graphic-bring-to-front") == 0) {
87
                                lg.before();
88
                                layout.getDocument().setModified(true);
89
                            } else
90
                                if (s.compareTo("layout-graphic-add-border") == 0) {
91
                                    if (lg.border()) {
92
                                        layout.getDocument().setModified(true);
93
                                    }
94
                                } else
95
                                    if (s.compareTo("layout-graphic-position") == 0) {
96
                                        lg.position();
97
                                        layout.getDocument().setModified(true);
98
                                    }
99
    }
100

  
101
    /**
102
     * @see com.iver.mdiApp.plugins.IExtension#isVisible()
103
     */
104
    public boolean isVisible() {
105
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
106

  
107
        if (f == null) {
108
            return false;
109
        }
110

  
111
        if (f instanceof LayoutPanel) {
112
            return true;
113
        }
114
        return false;
115
    }
116

  
117
    /**
118
     * @see org.gvsig.andami.plugins.IExtension#initialize()
119
     */
120
    public void initialize() {
121
        registerIcons();
122
    }
123

  
124
    private void registerIcons() {
125
        
126
        IconThemeHelper.registerIcon("action", "layout-graphic-group", this);
127
        IconThemeHelper.registerIcon("action", "layout-graphic-ungroup", this);
128
        IconThemeHelper.registerIcon("action", "layout-graphic-bring-to-front", this);
129
        IconThemeHelper.registerIcon("action", "layout-graphic-send-back", this);
130
        IconThemeHelper.registerIcon("action", "layout-graphic-position", this);
131
        IconThemeHelper.registerIcon("action", "layout-graphic-add-border", this);
132
    }
133

  
134
    /**
135
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
136
     */
137
    public boolean isEnabled() {
138
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
139
        if (!layout.getLayoutContext().isEditable())
140
            return false;
141
        return true;
142
    }
143
    
144
	protected LayoutPanel getLayout() {
145
		return layout;
146
	}
147
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutCommandStackExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.app.gui.command.CommandStackDialog;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29

  
30
public class LayoutCommandStackExtension extends Extension {
31

  
32
    private LayoutPanel layout = null;
33

  
34
    public void initialize() {
35
        registerIcons();
36
    }
37

  
38
    private void registerIcons() {
39
        IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this);
40
    }
41

  
42
    public void execute(String s) {
43
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
44
        if (s.equals("edit-undo-redo-actions-layout")) {
45
            CommandStackDialog csd = new CommandStackDialog();
46
            csd.setModel(layout.getLayoutContext().getFrameCommandsRecord());
47
            layout.getLayoutContext().getFrameCommandsRecord()
48
                .addObserver(layout);
49
            PluginServices.getMDIManager().addWindow(csd);
50
            layout.getDocument().setModified(true);
51
        }
52
    }
53

  
54
    public boolean isEnabled() {
55
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
56
        if (layout.getLayoutContext().isEditable())
57
            return true;
58
        return false;
59
    }
60

  
61
    public boolean isVisible() {
62
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
63
            return true;
64
        }
65
        return false;
66
    }
67

  
68
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutUndoExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.messages.NotificationManager;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
29
import org.gvsig.tools.undo.UndoException;
30

  
31
public class LayoutUndoExtension extends Extension {
32

  
33
    public void initialize() {
34
        registerIcons();
35
    }
36

  
37
    private void registerIcons() {
38
        
39
        IconThemeHelper.registerIcon("action", "edit-undo", this);
40
    }
41

  
42
    public void execute(String actionCommand) {
43
        LayoutPanel layout =
44
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
45
        if (actionCommand.equals("edit-undo-layout")) {
46
            try {
47
                layout.getLayoutContext().getFrameCommandsRecord().undo();
48
            } catch (UndoException e) {
49
                NotificationManager.showMessageError("Undo layout", e);
50
            }
51
            layout.getLayoutContext().updateFFrames();
52
            layout.getLayoutControl().refresh();
53
            layout.getDocument().setModified(true);
54
        }
55
    }
56

  
57
    public boolean isEnabled() {
58
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
59
            LayoutPanel layout =
60
                (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
61
            if (layout.getLayoutContext().getFrameCommandsRecord().canUndo()
62
                && layout.getLayoutContext().isEditable())
63
                return true;
64
        }
65
        return false;
66
    }
67

  
68
    public boolean isVisible() {
69
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
70
            return true;
71
        }
72
        return false;
73
    }
74

  
75
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/TagExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import java.awt.Component;
25

  
26
import javax.swing.JOptionPane;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
33
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
34

  
35
public class TagExtension extends Extension {
36

  
37
    private LayoutPanel layout = null;
38

  
39
    /**
40
     * @see org.gvsig.andami.plugins.IExtension#initialize()
41
     */
42
    public void initialize() {
43
        registerIcons();
44
    }
45

  
46
    private void registerIcons() {
47

  
48
        IconThemeHelper.registerIcon("action", "layout-graphic-show-tags", this);
49
        IconThemeHelper.registerIcon("action", "layout-insert-tag", this);
50

  
51
    }
52

  
53
    /**
54
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
55
     */
56
    public void execute(String s) {
57

  
58
        /*
59
         * FLayoutZooms zooms = new FLayoutZooms(layout);
60
         * logger.debug("Comand : " + s);
61
         * if (s.compareTo("SET_TAG") == 0) {
62
         * layout.setTool(Layout.SET_TAG);
63
         * }
64
         */
65

  
66
        // FJP: Cambio: abrimos la ventana de tag para
67
        // asignar el tag a los elementos seleccionados
68
        if (s.equals("layout-insert-tag")) {
69
            IFFrame[] selectedFrames =
70
                layout.getLayoutContext().getSelectedFFrames();
71
            if (selectedFrames.length > 0) {
72
                String defaultStr = "";
73
                if (selectedFrames.length == 1)
74
                    defaultStr = selectedFrames[0].getTag();
75
                String theTag =
76
                    JOptionPane.showInputDialog(
77
                        (Component) PluginServices.getMainFrame(),
78
                        "Introduzca el tag:", defaultStr);
79
                if (theTag != null) {
80
                    for (int i = 0; i < selectedFrames.length; i++)
81
                        selectedFrames[i].setTag(theTag);
82
                }
83
                layout.getDocument().setModified(true);
84
            }
85
        } else
86
            if (s.equals("layout-graphic-show-tags")) {
87
                // IFFrame[] frames = layout.getFFrames();
88
                // for (int i=0; i< frames.length; i++)
89
                // {
90
                // IFFrame f = frames[i];
91
                // if (f instanceof FFrameText)
92
                // {
93
                // FFrameText txt = (FFrameText) f;
94
                // if (f.getTag() != null)
95
                // {
96
                // txt.clearText();
97
                // txt.addText(f.getTag());
98
                // }
99
                // }
100
                // }
101
                layout.setShowIconTag(true);
102
                layout.getLayoutControl().refresh();
103
            }
104
    }
105

  
106
    /**
107
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
108
     */
109
    public boolean isEnabled() {
110
        IFFrame[] selectedFrames =
111
            layout.getLayoutContext().getSelectedFFrames();
112
        if (selectedFrames == null)
113
            return false;
114
        return (selectedFrames.length > 0);
115
    }
116

  
117
    /**
118
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
119
     */
120
    public boolean isVisible() {
121
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
122

  
123
        if (f != null && f instanceof LayoutPanel) {
124
            layout = (LayoutPanel) f;
125
            return true;
126
        }
127
        return false;
128
    }
129

  
130
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/PrintProperties.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
/**
25
 */
26
import java.awt.geom.Rectangle2D;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.plugins.Extension;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33

  
34
/**
35
 * DOCUMENT ME!
36
 * 
37
 * @author vcn
38
 */
39
public class PrintProperties extends Extension /*
40
                                                * implements
41
                                                * IPreferenceExtension
42
                                                */{
43

  
44
    private LayoutPanel l;
45
    // private static final IPreference printPropertiesPage = new
46
    // PrintPropertiesPage();
47
    // private Paper paper;
48
    Rectangle2D.Double aux = null;
49

  
50
    /**
51
     * DOCUMENT ME!
52
     * 
53
     * @param s
54
     *            DOCUMENT ME!
55
     */
56
    public void execute(String s) {
57
        if (s.compareTo("application-page-setup-layout") == 0) {
58
            l = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
59
            l.showFConfig();
60
        }
61
    }
62

  
63
    /**
64
     * DOCUMENT ME!
65
     * 
66
     * @return DOCUMENT ME!
67
     */
68
    public boolean isVisible() {
69
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
70

  
71
        if (f == null) {
72
            return false;
73
        }
74

  
75
        return (f instanceof LayoutPanel);
76
    }
77

  
78
    /**
79
     * @see com.iver.mdiApp.plugins.IExtension#isEnabled()
80
     */
81
    public boolean isEnabled() {
82
        LayoutPanel f =
83
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
84

  
85
        if (f == null || !f.getLayoutContext().isEditable()) {
86
            return false;
87
        }
88

  
89
        return true;
90
    }
91

  
92
    /**
93
     * @see org.gvsig.andami.plugins.IExtension#initialize()
94
     */
95
    public void initialize() {
96
        registerIcons();
97
    }
98

  
99
    private void registerIcons() {
100
        IconThemeHelper.registerIcon("action", "application-page-setup", this);
101
    }
102
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import java.awt.Component;
25
import java.io.File;
26
import java.io.FileOutputStream;
27

  
28
import javax.swing.JFileChooser;
29
import javax.swing.JOptionPane;
30

  
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

  
34
import org.gvsig.andami.IconThemeHelper;
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.andami.messages.NotificationManager;
37
import org.gvsig.andami.plugins.Extension;
38
import org.gvsig.andami.preferences.IPreference;
39
import org.gvsig.andami.preferences.IPreferenceExtension;
40
import org.gvsig.andami.ui.mdiManager.IWindow;
41
import org.gvsig.app.gui.preferencespage.LayoutPage;
42
import org.gvsig.app.project.documents.layout.FLayoutZooms;
43
import org.gvsig.app.project.documents.layout.LayoutManager;
44
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
45
import org.gvsig.app.project.documents.layout.report.LayoutReportActionFactory;
46
import org.gvsig.i18n.Messages;
47
import org.gvsig.tools.ToolsLocator;
48
import org.gvsig.tools.persistence.PersistenceManager;
49
import org.gvsig.tools.persistence.PersistentState;
50
import org.gvsig.tools.persistence.text.JavaTextFactory;
51
import org.gvsig.utils.GenericFileFilter;
52

  
53
/**
54
 * Extensi?n para controlar las operaciones basicas sobre el Layout.
55
 * 
56
 * @author Vicente Caballero Navarro
57
 */
58
public class LayoutExtension extends Extension implements IPreferenceExtension {
59

  
60
    private static final Logger logger = LoggerFactory
61
            .getLogger(LayoutExtension.class);
62

  
63
    private LayoutPanel layout = null;
64

  
65
    /**
66
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
67
     */
68
    public void execute(String s) {
69
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
70

  
71
        FLayoutZooms zooms = new FLayoutZooms(layout);
72
        logger.debug("Comand : " + s);
73

  
74
        if (s.equals("layout-navigation-pan")) {
75
            layout.getLayoutControl().setTool("layoutpan");
76
        }
77
        else if (s.equals("layout-navigation-zoom-in-topoint")) {
78
            layout.getLayoutControl().setTool("layoutzoomin");
79
        }
80
        else if (s.equals("layout-navigation-zoom-out-topoint")) {
81
            layout.getLayoutControl().setTool("layoutzoomout");
82
        }
83
        else if (s.equals("layout-navigation-zoom-all")) {
84
            layout.getLayoutControl().fullRect();
85
        }
86
        else if (s.equals("layout-navigation-zoom-real")) {
87
            zooms.realZoom();
88
        }
89
        else if (s.equals("layout-navigation-zoom-out-center")) {
90
            zooms.zoomOut();
91
        }
92
        else if (s.equals("layout-navigation-zoom-in-center")) {
93
            zooms.zoomIn();
94
        }
95
        else if (s.equals("layout-navigation-zoom-selected")) {
96
            zooms.zoomSelect();
97
        }
98
        else if (s.equals("application-layout-template-save")) {
99
            saveLayout();
100
        }
101
    }
102

  
103
    private void saveLayout() {
104
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
105
        JFileChooser jfc = new JFileChooser();
106
        GenericFileFilter layoutMainFilter = new GenericFileFilter(
107
                LayoutManager.TEMPLATE_FILE_POINTEXT,
108
                Messages.getText("_Layout_template") + " (*"
109
                        + LayoutManager.TEMPLATE_FILE_POINTEXT + ")");
110
        jfc.addChoosableFileFilter(layoutMainFilter);
111
        jfc.setFileFilter(layoutMainFilter);
112

  
113
        if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
114
            File file = jfc.getSelectedFile();
115
            if (!(file.getPath().endsWith(
116
                    LayoutManager.TEMPLATE_FILE_POINTEXT.toLowerCase()) || file
117
                    .getPath().endsWith(LayoutManager.TEMPLATE_FILE_POINTEXT))) {
118
                file = new File(file.getPath()
119
                        + LayoutManager.TEMPLATE_FILE_POINTEXT);
120
            }
121
            if (file.exists()) {
122
                int resp = JOptionPane.showConfirmDialog(
123
                        (Component) PluginServices.getMainFrame(),
124
                        PluginServices.getText(this,
125
                                "fichero_ya_existe_seguro_desea_guardarlo"),
126
                        PluginServices.getText(this, "guardar"),
127
                        JOptionPane.YES_NO_OPTION);
128
                if (resp != JOptionPane.YES_OPTION) {
129
                    return;
130
                }
131
            }
132

  
133
            try {
134
                FileOutputStream fos = new FileOutputStream(
135
                        file.getAbsolutePath());
136
                PersistenceManager persistenceManager = ToolsLocator
137
                        .getPersistenceManager();
138
                PersistentState persistentState = persistenceManager
139
                        .getState(layout);
140
                persistenceManager.saveState(persistentState, fos);
141
            }
142
            catch (Exception e) {
143
                NotificationManager.addError(PluginServices.getText(this,
144
                        "Error_guardando_la_plantilla"), e);
145
            }
146
        }
147
    }
148

  
149
    /**
150
     * @see com.iver.mdiApp.plugins.IExtension#isVisible()
151
     */
152
    public boolean isVisible() {
153
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
154

  
155
        if (f == null) {
156
            return false;
157
        }
158

  
159
        if (f instanceof LayoutPanel) {
160
            return true;
161
        }
162
        return false;
163
    }
164

  
165
    /**
166
     * @see org.gvsig.andami.plugins.IExtension#initialize()
167
     */
168
    public void initialize() {
169
        registerPersistence();
170
        registerIcons();
171
    }
172

  
173
    @Override
174
    public void postInitialize() {
175
        LayoutReportActionFactory.selfRegister();
176
    }
177
    
178
    private void registerPersistence() {
179
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
180
        JavaTextFactory factory = new JavaTextFactory();
181
        manager.registerFactory(factory);
182
    }
183

  
184
    private void registerIcons() {
185

  
186
        IconThemeHelper.registerIcon("action",
187
                "application-layout-template-save", this);
188

  
189
        IconThemeHelper.registerIcon("action",
190
                "layout-navigation-zoom-in-center", this);
191
        IconThemeHelper.registerIcon("action",
192
                "layout-navigation-zoom-out-center", this);
193
        IconThemeHelper.registerIcon("action",
194
                "layout-navigation-zoom-in-topoint", this);
195
        IconThemeHelper.registerIcon("action",
196
                "layout-navigation-zoom-out-topoint", this);
197
        IconThemeHelper.registerIcon("action", "layout-navigation-zoom-all",
198
                this);
199
        IconThemeHelper.registerIcon("action", "layout-navigation-zoom-real",
200
                this);
201
        IconThemeHelper.registerIcon("action",
202
                "layout-navigation-zoom-selected", this);
203
        IconThemeHelper.registerIcon("action", "layout-navigation-pan", this);
204

  
205
        IconThemeHelper.registerIcon("action",
206
                "layout-view-navigation-zoom-in-topoint", this);
207
        IconThemeHelper.registerIcon("action",
208
                "layout-view-navigation-zoom-out-topoint", this);
209
        IconThemeHelper.registerIcon("action",
210
                "layout-view-navigation-zoom-all", this);
211
        IconThemeHelper.registerIcon("action", "layout-view-navigation-pan",
212
                this);
213
        // ================================================
214
        // Cursors
215
        IconThemeHelper.registerIcon("cursor",
216
                "cursor-layout-navigation-zoom-in-topoint", this);
217
        IconThemeHelper.registerIcon("cursor",
218
                "cursor-layout-navigation-zoom-out-topoint", this);
219
        IconThemeHelper.registerIcon("cursor", "cursor-selection-by-rectangle",
220
                this);
221
        IconThemeHelper.registerIcon("cursor", "cursor-selection-simple", this);
222
        IconThemeHelper
223
                .registerIcon("cursor", "cursor-selection-complex", this);
224
        IconThemeHelper.registerIcon("cursor",
225
                "cursor-layout-graphic-edit-vertex", this);
226
        IconThemeHelper.registerIcon("cursor", "cursor-layout-insert-circle",
227
                this);
228
        IconThemeHelper.registerIcon("cursor", "cursor-layout-insert-polyline",
229
                this);
230
        IconThemeHelper.registerIcon("cursor", "cursor-layout-insert-point",
231
                this);
232
        IconThemeHelper.registerIcon("cursor", "cursor-layout-insert-polygon",
233
                this);
234
        IconThemeHelper.registerIcon("cursor",
235
                "cursor-layout-insert-rectangle", this);
236
        IconThemeHelper.registerIcon("cursor",
237
                "cursor-layout-view-navigation-zoom-in-topoint", this);
238
        IconThemeHelper.registerIcon("cursor",
239
                "cursor-layout-view-navigation-zoom-out-topoint", this);
240
        // End cursors
241
        // ================================================
242

  
243
        IconThemeHelper.registerIcon("document", "document-map-icon", this);
244
        IconThemeHelper.registerIcon("document", "document-map-icon-sel", this);
245

  
246
        IconThemeHelper.registerIcon("layout", "neresize-icon", this);
247
        IconThemeHelper.registerIcon("layout", "eresize-icon", this);
248
        IconThemeHelper.registerIcon("layout", "nresize-icon", this);
249
        IconThemeHelper.registerIcon("layout", "graphic-move-icon", this);
250

  
251
        IconThemeHelper.registerIcon("layout", "sereresize-icon", this);
252
        IconThemeHelper.registerIcon("layout", "symboltag-icon", this);
253
        IconThemeHelper.registerIcon("layout", "numero-icon", this);
254
        IconThemeHelper.registerIcon("layout", "barra1-icon", this);
255
        IconThemeHelper.registerIcon("layout", "barra2-icon", this);
256
        IconThemeHelper.registerIcon("layout", "barra3-icon", this);
257

  
258
        IconThemeHelper.registerIcon("layout", "text-left-icon", this);
259
        IconThemeHelper.registerIcon("layout", "text-center-v-icon", this);
260
        IconThemeHelper.registerIcon("layout", "text-right-icon", this);
261
        IconThemeHelper.registerIcon("layout", "left-rotation-icon", this);
262
        IconThemeHelper.registerIcon("layout", "text-up-icon", this);
263
        IconThemeHelper.registerIcon("layout", "text-center-h-icon", this);
264
        IconThemeHelper.registerIcon("layout", "text-down-icon", this);
265
        IconThemeHelper.registerIcon("layout", "text-distup-icon", this);
266
        IconThemeHelper.registerIcon("layout", "text-distcenterh-icon", this);
267
        IconThemeHelper.registerIcon("layout", "text-distdown-icon", this);
268
        IconThemeHelper.registerIcon("layout", "text-distleft-icon", this);
269

  
270
        IconThemeHelper.registerIcon("layout", "text-distcenterv-icon", this);
271
        IconThemeHelper.registerIcon("layout", "text-distright-icon", this);
272
        IconThemeHelper.registerIcon("layout", "text-size-width-icon", this);
273
        IconThemeHelper.registerIcon("layout", "text-size-height-icon", this);
274
        IconThemeHelper.registerIcon("layout", "text-size-other-icon", this);
275
        IconThemeHelper.registerIcon("layout", "text-space-right-icon", this);
276
        IconThemeHelper.registerIcon("layout", "text-space-down-icon", this);
277
        IconThemeHelper.registerIcon("layout", "text-inlayout-icon", this);
278
        IconThemeHelper.registerIcon("layout", "layout-pan-icon", this);
279
        IconThemeHelper.registerIcon("layout", "view-pan-icon", this);
280
        IconThemeHelper.registerIcon("layout", "right-rotation-icon", this);
281
    }
282

  
283
    /**
284
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
285
     */
286
    public boolean isEnabled() {
287
        return true;
288
    }
289

  
290
    /**
291
     * Devuelve el Layout sobre el que se opera.
292
     * 
293
     * @return Layout.
294
     */
295
    public LayoutPanel getLayout() {
296
        return layout;
297
    }
298

  
299
    public IPreference[] getPreferencesPages() {
300
        return new IPreference[] { new LayoutPage() };
301
    }
302
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/ExportLayoutExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import java.io.File;
25
import org.gvsig.andami.IconThemeHelper;
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.plugins.Extension;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
30
import org.gvsig.tools.util.ArrayUtils;
31

  
32
/**
33
 * Extension for exporting the layout to PDF or PostScript.
34
 *
35
 * @author jaume dominguez faus - jaume.dominguez@iver.es
36
 */
37
public class ExportLayoutExtension extends Extension {
38

  
39
    private LayoutPanel layoutPanel;
40

  
41
    public void initialize() {
42
        registerIcons();
43
    }
44

  
45
    private void registerIcons() {
46

  
47
        IconThemeHelper.registerIcon("action", "application-export-to-postscript", this);
48
        IconThemeHelper.registerIcon("action", "application-export-to-pdf", this);
49
    }
50

  
51
    /**
52
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
53
     */
54
    public void execute(String s) {
55
        this.execute(s, null);
56
    }
57

  
58
    @Override
59
    public void execute(String command, Object[] args) {
60
        layoutPanel = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
61
        if (command.equals("application-export-to-pdf")) {
62
            Object file = ArrayUtils.get(args, 0);
63
            if( file instanceof String ) {
64
                file = new File((String)file);
65
            }
66
            if( file == null ) {
67
                layoutPanel.layoutToPDF();
68
            } else {
69
                layoutPanel.layoutToPDF((File)file);
70
            }
71
        } else if (command.equals("application-export-to-postscript")) {
72
            layoutPanel.layoutToPS();
73
        }
74
    }
75

  
76
    public boolean isEnabled() {
77
        return true;
78
    }
79

  
80
    public boolean isVisible() {
81
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
82

  
83
        if (f == null) {
84
            return false;
85
        }
86

  
87
        if (f instanceof LayoutPanel) {
88
            // Layout layout = (Layout) f;
89

  
90
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
91
            // > 0;
92
        } else {
93
            return false;
94
        }
95
    }
96

  
97
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/FFrameLegendExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.extension;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.app.project.documents.layout.FLayoutGraphics;
28
import org.gvsig.app.project.documents.layout.fframes.FFrameLegend;
29
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
30
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
31

  
32
/**
33
 * Extensi?n preparada para controlar las opciones que se pueden realizar sobre
34
 * una vista a?adida en el Layout.
35
 * 
36
 * @author Vicente Caballero Navarro
37
 */
38
public class FFrameLegendExtension extends Extension {
39

  
40
    private LayoutPanel layout = null;
41

  
42
    /**
43
     * @see org.gvsig.andami.plugins.IExtension#initialize()
44
     */
45
    public void initialize() {
46
    }
47

  
48
    /**
49
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
50
     */
51
    public void execute(String s) {
52
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
53
        FLayoutGraphics lg = new FLayoutGraphics(layout);
54
        if (s.compareTo("layout-graphic-simplify-legend") == 0) {
55
            lg.simplify();
56
            layout.getDocument().setModified(true);
57
        }
58
    }
59

  
60
    /**
61
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
62
     */
63
    public boolean isEnabled() {
64
        LayoutPanel l =
65
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
66
        IFFrame[] fframes = l.getLayoutContext().getSelectedFFrames();
67
        if (!l.getLayoutContext().isEditable())
68
            return false;
69
        for (int i = 0; i < fframes.length; i++) {
70
            if (fframes[i] instanceof FFrameLegend) {
71
                return true;
72
            }
73
        }
74

  
75
        return false;
76
    }
77

  
78
    /**
79
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
80
     */
81
    public boolean isVisible() {
82
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
83

  
84
        if (f == null) {
85
            return false;
86
        }
87

  
88
        if (f instanceof LayoutPanel) {
89
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
90
                         // > 0;
91
        } else {
92
            return false;
93
        }
94
    }
95
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/reportfromlayout/ExportReportToLayoutPanelView.java
1
package org.gvsig.app.extension.reportfromlayout;
2

  
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6
import java.awt.BorderLayout;
7
import java.awt.ComponentOrientation;
8
import java.awt.Container;
9
import java.awt.Dimension;
10
import javax.swing.Box;
11
import javax.swing.ImageIcon;
12
import javax.swing.JButton;
13
import javax.swing.JComboBox;
14
import javax.swing.JFrame;
15
import javax.swing.JLabel;
16
import javax.swing.JPanel;
17
import javax.swing.JScrollPane;
18
import javax.swing.JTextField;
19
import javax.swing.JTree;
20
import javax.swing.border.EmptyBorder;
21

  
22

  
23
public class ExportReportToLayoutPanelView extends JPanel
24
{
25
   JLabel lblSource = new JLabel();
26
   JLabel lblReport = new JLabel();
27
   JComboBox cboReport = new JComboBox();
28
   JTree treeSource = new JTree();
29
   JTextField txtFile = new JTextField();
30
   JLabel lblFile = new JLabel();
31
   JButton btnFile = new JButton();
32

  
33
   /**
34
    * Default constructor
35
    */
36
   public ExportReportToLayoutPanelView()
37
   {
38
      initializePanel();
39
   }
40

  
41
   /**
42
    * Adds fill components to empty cells in the first row and first column of the grid.
43
    * This ensures that the grid spacing will be the same as shown in the designer.
44
    * @param cols an array of column indices in the first row where fill components should be added.
45
    * @param rows an array of row indices in the first column where fill components should be added.
46
    */
47
   void addFillComponents( Container panel, int[] cols, int[] rows )
48
   {
49
      Dimension filler = new Dimension(10,10);
50

  
51
      boolean filled_cell_11 = false;
52
      CellConstraints cc = new CellConstraints();
53
      if ( cols.length > 0 && rows.length > 0 )
54
      {
55
         if ( cols[0] == 1 && rows[0] == 1 )
56
         {
57
            /** add a rigid area  */
58
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
59
            filled_cell_11 = true;
60
         }
61
      }
62

  
63
      for( int index = 0; index < cols.length; index++ )
64
      {
65
         if ( cols[index] == 1 && filled_cell_11 )
66
         {
67
            continue;
68
         }
69
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
70
      }
71

  
72
      for( int index = 0; index < rows.length; index++ )
73
      {
74
         if ( rows[index] == 1 && filled_cell_11 )
75
         {
76
            continue;
77
         }
78
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
79
      }
80

  
81
   }
82

  
83
   /**
84
    * Helper method to load an image file from the CLASSPATH
85
    * @param imageName the package and name of the file to load relative to the CLASSPATH
86
    * @return an ImageIcon instance with the specified image file
87
    * @throws IllegalArgumentException if the image resource cannot be loaded.
88
    */
89
   public ImageIcon loadImage( String imageName )
90
   {
91
      try
92
      {
93
         ClassLoader classloader = getClass().getClassLoader();
94
         java.net.URL url = classloader.getResource( imageName );
95
         if ( url != null )
96
         {
97
            ImageIcon icon = new ImageIcon( url );
98
            return icon;
99
         }
100
      }
101
      catch( Exception e )
102
      {
103
         e.printStackTrace();
104
      }
105
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
106
   }
107

  
108
   /**
109
    * Method for recalculating the component orientation for 
110
    * right-to-left Locales.
111
    * @param orientation the component orientation to be applied
112
    */
113
   public void applyComponentOrientation( ComponentOrientation orientation )
114
   {
115
      // Not yet implemented...
116
      // I18NUtils.applyComponentOrientation(this, orientation);
117
      super.applyComponentOrientation(orientation);
118
   }
119

  
120
   public JPanel createPanel()
121
   {
122
      JPanel jpanel1 = new JPanel();
123
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
124
      CellConstraints cc = new CellConstraints();
125
      jpanel1.setLayout(formlayout1);
126

  
127
      lblSource.setName("lblSource");
128
      lblSource.setText("_Source");
129
      lblSource.setVerticalAlignment(JLabel.TOP);
130
      jpanel1.add(lblSource,new CellConstraints(2,2,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
131

  
132
      lblReport.setName("lblReport");
133
      lblReport.setText("_Report");
134
      jpanel1.add(lblReport,cc.xy(2,4));
135

  
136
      cboReport.setName("cboReport");
137
      jpanel1.add(cboReport,cc.xywh(4,4,3,1));
138

  
139
      treeSource.setName("treeSource");
140
      treeSource.setRootVisible(false);
141
      JScrollPane jscrollpane1 = new JScrollPane();
142
      jscrollpane1.setViewportView(treeSource);
143
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
144
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
145
      jpanel1.add(jscrollpane1,new CellConstraints(4,2,3,1,CellConstraints.DEFAULT,CellConstraints.FILL));
146

  
147
      txtFile.setName("txtFile");
148
      jpanel1.add(txtFile,cc.xy(4,6));
149

  
150
      lblFile.setName("lblFile");
151
      lblFile.setText("_File");
152
      jpanel1.add(lblFile,cc.xy(2,6));
153

  
154
      btnFile.setActionCommand("JButton");
155
      btnFile.setName("btnFile");
156
      btnFile.setText("...");
157
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
158
      btnFile.setBorder(emptyborder1);
159
      jpanel1.add(btnFile,cc.xy(6,6));
160

  
161
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5,6,7 });
162
      return jpanel1;
163
   }
164

  
165
   /**
166
    * Initializer
167
    */
168
   protected void initializePanel()
169
   {
170
      setLayout(new BorderLayout());
171
      add(createPanel(), BorderLayout.CENTER);
172
   }
173

  
174

  
175
}
tags/org.gvsig.app.document.layout2.app-2.0.289/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/reportfromlayout/ConfigureReportFromLayoutPanelView.java
1
package org.gvsig.app.extension.reportfromlayout;
2

  
3
import com.jeta.forms.components.separator.TitledSeparator;
4
import com.jeta.open.i18n.I18NUtils;
5
import com.jgoodies.forms.layout.CellConstraints;
6
import com.jgoodies.forms.layout.FormLayout;
7
import java.awt.BorderLayout;
8
import java.awt.ComponentOrientation;
9
import java.awt.Container;
10
import java.awt.Dimension;
11
import javax.swing.Box;
12
import javax.swing.ImageIcon;
13
import javax.swing.JButton;
14
import javax.swing.JCheckBox;
15
import javax.swing.JComboBox;
16
import javax.swing.JFrame;
17
import javax.swing.JLabel;
18
import javax.swing.JPanel;
19
import javax.swing.JScrollPane;
20
import javax.swing.JTextField;
21
import javax.swing.JTree;
22

  
23

  
24
public class ConfigureReportFromLayoutPanelView extends JPanel
25
{
26
   JLabel lblLayout = new JLabel();
27
   JLabel lblSource = new JLabel();
28
   JLabel lblReport = new JLabel();
29
   JLabel lblIdentifier = new JLabel();
30
   JLabel lblLabel = new JLabel();
31
   JCheckBox chkUseInternalPdfViewer = new JCheckBox();
32
   JComboBox cboLayout = new JComboBox();
33
   JTree treeSource = new JTree();
34
   JComboBox cboReport = new JComboBox();
35
   JTextField txtIdentifier = new JTextField();
36
   JTextField txtLabel = new JTextField();
37
   TitledSeparator lblViewSeparator = new TitledSeparator();
38
   JLabel lblView = new JLabel();
39
   JComboBox cboView = new JComboBox();
40
   JCheckBox chkHighlightRecord = new JCheckBox();
41
   JCheckBox chkZoomToCurrentRow = new JCheckBox();
42
   JLabel lblBufferSize = new JLabel();
43
   JTextField txtBufferSize = new JTextField();
44
   JCheckBox chkCenterToCurrentRow = new JCheckBox();
45
   JLabel lblAppySymbolTo = new JLabel();
46
   JComboBox cboApplySymbolTo = new JComboBox();
47
   JButton btnSelectSymbol = new JButton();
48

  
49
   /**
50
    * Default constructor
51
    */
52
   public ConfigureReportFromLayoutPanelView()
53
   {
54
      initializePanel();
55
   }
56

  
57
   /**
58
    * Adds fill components to empty cells in the first row and first column of the grid.
59
    * This ensures that the grid spacing will be the same as shown in the designer.
60
    * @param cols an array of column indices in the first row where fill components should be added.
61
    * @param rows an array of row indices in the first column where fill components should be added.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff