Revision 42037

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometry.app/org.gvsig.geometry.app.generalpath/src/main/java/org/gvsig/geometry/app/generalpath/FlatnessExtension.java
1
package org.gvsig.geometry.app.generalpath;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.plugins.Extension;
5
import org.gvsig.fmap.geom.GeometryLocator;
6
import org.gvsig.fmap.geom.GeometryManager;
7
import org.gvsig.tools.ToolsLocator;
8
import org.gvsig.tools.extensionpoint.ExtensionPoint;
9
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
10

  
11

  
12
public class FlatnessExtension extends Extension {
13

  
14
    public void initialize() {
15
        IconThemeHelper.registerIcon("preferences", "preferences-layer-modify-flatness", this);
16

  
17
        Double flatness =
18
            (Double) getPlugin().getPluginProperties().getDynValue("flatness");
19
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
20
        geomManager.setFlatness(flatness.doubleValue());
21
    }
22

  
23
    public void execute(String actionCommand) {
24
        // TODO Auto-generated method stub
25

  
26
    }
27

  
28
    public boolean isEnabled() {
29
        // TODO Auto-generated method stub
30
        return false;
31
    }
32

  
33
    public boolean isVisible() {
34
        // TODO Auto-generated method stub
35
        return false;
36
    }
37

  
38
    public void postInitialize() {
39
        ExtensionPointManager extensionPoints =
40
            ToolsLocator.getExtensionPointManager();
41
        ExtensionPoint ep = extensionPoints.add("AplicationPreferences", "");
42
        ep.append("Flatness", "", new FlatnessPage());
43
    }
44

  
45
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometry.app/org.gvsig.geometry.app.generalpath/src/main/java/org/gvsig/geometry/app/generalpath/FlatnessPage.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.geometry.app.generalpath;
25

  
26

  
27

  
28

  
29
import java.awt.BorderLayout;
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
import java.awt.Insets;
33
import java.awt.event.KeyEvent;
34
import java.awt.event.KeyListener;
35

  
36
import javax.swing.ImageIcon;
37
import javax.swing.JLabel;
38
import javax.swing.JPanel;
39
import javax.swing.JTextArea;
40
import javax.swing.JTextField;
41
import javax.swing.border.EmptyBorder;
42

  
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

  
46
import org.gvsig.andami.IconThemeHelper;
47
import org.gvsig.andami.PluginServices;
48
import org.gvsig.andami.PluginsLocator;
49
import org.gvsig.andami.PluginsManager;
50
import org.gvsig.andami.preferences.AbstractPreferencePage;
51
import org.gvsig.andami.preferences.StoreException;
52
import org.gvsig.fmap.geom.GeometryLocator;
53
import org.gvsig.fmap.geom.GeometryManager;
54
import org.gvsig.tools.ToolsLocator;
55
import org.gvsig.tools.dynobject.DynObject;
56
import org.gvsig.tools.i18n.I18nManager;
57

  
58

  
59

  
60
public class FlatnessPage extends AbstractPreferencePage implements KeyListener  {
61

  
62
    /**
63
     *
64
     */
65
    private static final long serialVersionUID = -6521882508307037082L;
66

  
67
    private static final Logger logger = LoggerFactory.getLogger(FlatnessPage.class);
68

  
69
    public static final String ID = FlatnessPage.class.getName();
70

  
71
    private JPanel flatnessPanel;
72
    private JTextArea jTextArea = null;
73
    private JTextField txtFlatness;
74
	private boolean valChanged = false;
75

  
76
    private DynObject pluginProperties;
77
    private PluginServices plugin;
78

  
79
    private ImageIcon icon;
80

  
81

  
82

  
83
    public FlatnessPage() {
84
        initComponents();
85
    }
86

  
87
    private void initComponents() {
88
        icon = IconThemeHelper.getImageIcon("preferences-layer-modify-flatness");
89
        PluginsManager pluginManager = PluginsLocator.getManager();
90
        this.plugin = pluginManager.getPlugin(this);
91
        this.pluginProperties = this.plugin.getPluginProperties();
92

  
93
        this.flatnessPanel = getFlatnessPanel();
94

  
95
        this.setLayout(new BorderLayout());
96
        this.add(this.flatnessPanel, BorderLayout.NORTH);
97
        initializeValues();
98
    }
99

  
100
    public void storeValues() throws StoreException {
101

  
102
      double flatness;
103
      try{
104
          flatness=Double.parseDouble(txtFlatness.getText());
105
      }catch (Exception e) {
106
          throw new StoreException(PluginServices.getText(this,"minimum_size_of_line_incorrect"));
107
      }
108
      GeometryManager geometryManager = GeometryLocator.getGeometryManager();
109
      geometryManager.setFlatness(flatness);
110

  
111
      this.pluginProperties.setDynValue("flatness", flatness);
112
      this.plugin.savePluginProperties();
113
    }
114

  
115
    public void setChangesApplied() {
116
      setChanged(false);
117
    }
118

  
119
    public String getID() {
120
        return ID;
121
    }
122

  
123
    public String getTitle() {
124
        I18nManager i18nManager = ToolsLocator.getI18nManager();
125
        return i18nManager.getTranslation("Flatness");
126
    }
127

  
128
    public JPanel getPanel() {
129
        return this;
130
    }
131

  
132
    public void initializeValues() {
133
        Double flatness = (Double) pluginProperties.getDynValue("flatness");
134
        txtFlatness.setText(String.valueOf(flatness));
135
        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
136
        geometryManager.setFlatness(flatness.doubleValue());
137
    }
138

  
139
    public void initializeDefaults() {
140
        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
141
        txtFlatness.setText(String.valueOf(geometryManager.getFlatness()));
142
    }
143

  
144
    public ImageIcon getIcon() {
145
        return this.icon;
146
    }
147

  
148
    public boolean isValueChanged() {
149
        return valChanged;
150
    }
151

  
152
    public boolean isResizeable() {
153
      return true;
154
    }
155

  
156

  
157
  public JPanel getFlatnessPanel(){
158
  if (flatnessPanel == null){
159
      flatnessPanel = new JPanel();
160
      flatnessPanel.setLayout(new GridBagLayout());
161
      flatnessPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
162

  
163
      GridBagConstraints constraints = new GridBagConstraints();
164
      constraints.gridx = 0;
165
      constraints.gridy = 0;
166
      constraints.fill = GridBagConstraints.HORIZONTAL;
167
      constraints.weightx = 1.0;
168
      constraints.gridwidth = 2;
169
      constraints.insets = new Insets(0, 0, 5, 0);
170
      flatnessPanel.add(getJTextArea(), constraints);
171

  
172
      constraints = new GridBagConstraints();
173
      constraints.gridx = 0;
174
      constraints.gridy = 1;
175
      flatnessPanel.add(new JLabel(PluginServices.getText(this, "densityfication") + ":"), constraints);
176

  
177
      txtFlatness = new JTextField("", 15);
178
      txtFlatness.addKeyListener(this);
179
      constraints = new GridBagConstraints();
180
      constraints.gridx = 1;
181
      constraints.gridy = 1;
182
      constraints.fill = GridBagConstraints.HORIZONTAL;
183
      constraints.weightx = 1.0;
184
      flatnessPanel.add(txtFlatness, constraints);
185
  }
186
  return flatnessPanel;
187
}
188

  
189
	/**
190
	 * This method initializes jTextArea
191
	 *
192
	 * @return javax.swing.JTextArea
193
	 */
194
	private JTextArea getJTextArea() {
195
		if (jTextArea == null) {
196
			jTextArea = new JTextArea();
197
			jTextArea.setBounds(new java.awt.Rectangle(13,7,285,57));
198
			jTextArea.setForeground(java.awt.Color.black);
199
			jTextArea.setBackground(java.awt.SystemColor.control);
200
			jTextArea.setRows(3);
201
			jTextArea.setWrapStyleWord(true);
202
			jTextArea.setLineWrap(true);
203
			jTextArea.setEditable(false);
204
			jTextArea.setText(PluginServices.getText(this,"specifies_the_minimum_size_of_the_lines_that_will_form_the_curves"));
205
		}
206
		return jTextArea;
207
	}
208

  
209
    public void keyTyped(KeyEvent e) {
210
        valChanged = true;
211
    }
212

  
213
    public void keyPressed(KeyEvent e) {
214
        valChanged = true;
215
    }
216

  
217
    public void keyReleased(KeyEvent e) {
218
        // do nothing
219
    }
220
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometry.app/org.gvsig.geometry.app.generalpath/src/main/resources-plugin/config.xml
34 34
      description=""
35 35
      active="true">
36 36
    </extension>
37
    <extension class-name="org.gvsig.geometry.app.generalpath.FlatnessExtension"
38
      description="Support flatness preference"
39
      active="true">
40
    </extension>
41

  
37 42
  </extensions>
38 43

  
39 44
</plugin-config>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometry.app/org.gvsig.geometry.app.generalpath/src/main/resources-plugin/plugin-persistence.def
1
<?xml version="1.0"?>
2
<!--
3
Definitions of plugin persistence org.gvsig.geometry.
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    <class name="org.gvsig.geometry.app.generalpath">
9
      <description>Persistence for the core plugin</description>
10
      <fields>
11

  
12
        <field name="flatness" type="Double" defaultValue="0.8" mandatory="true">
13
          <description></description>
14
        </field>
15

  
16
      </fields>
17
    </class>
18
  </classes>
19
</definitions>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometry.app/org.gvsig.geometry.app.generalpath/pom.xml
27 27
          <artifactId>slf4j-api</artifactId>
28 28
          <scope>compile</scope>
29 29
      </dependency>
30
 
30

  
31 31
       <dependency>
32 32
           <groupId>com.vividsolutions</groupId>
33 33
           <artifactId>jts</artifactId>
......
36 36
       <dependency>
37 37
           <groupId>org.gvsig</groupId>
38 38
           <artifactId>org.gvsig.fmap.geometry.api</artifactId>
39
     		<scope>runtime</scope>
39
     		<scope>compile</scope>
40 40
       </dependency>
41 41
       <dependency>
42 42
           <groupId>org.gvsig</groupId>
......
48 48
           <artifactId>org.gvsig.fmap.geometry.operation</artifactId>
49 49
     		<scope>runtime</scope>
50 50
       </dependency>
51
            
51

  
52 52
  </dependencies>
53 53

  
54 54
  <properties>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/GridPage.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: GridPage.java 21668 2008-06-19 09:05:14Z vcaballero $
27
* $Log$
28
* Revision 1.4  2006-08-22 12:27:53  jaume
29
* improved performances when saving
30
*
31
* Revision 1.3  2006/08/22 07:37:32  jaume
32
* *** empty log message ***
33
*
34
* Revision 1.2  2006/08/10 11:13:02  caballero
35
* mostrar unidades
36
*
37
* Revision 1.1  2006/08/10 08:18:35  caballero
38
* configurar grid
39
*
40
* Revision 1.1  2006/08/04 11:41:05  caballero
41
* poder especificar el zoom a aplicar en las vistas
42
*
43
* Revision 1.3  2006/07/31 10:02:31  jaume
44
* *** empty log message ***
45
*
46
* Revision 1.2  2006/06/13 07:43:08  fjp
47
* Ajustes sobre los cuadros de dialogos de preferencias
48
*
49
* Revision 1.1  2006/06/12 16:04:28  caballero
50
* Preferencias
51
*
52
* Revision 1.11  2006/06/06 10:26:31  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.10  2006/06/05 17:07:17  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.9  2006/06/05 17:00:44  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.8  2006/06/05 16:57:59  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.7  2006/06/05 14:45:06  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.6  2006/06/05 11:00:09  jaume
68
* *** empty log message ***
69
*
70
* Revision 1.5  2006/06/05 10:39:02  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.4  2006/06/05 10:13:40  jaume
74
* *** empty log message ***
75
*
76
* Revision 1.3  2006/06/05 10:06:08  jaume
77
* *** empty log message ***
78
*
79
* Revision 1.2  2006/06/05 09:51:56  jaume
80
* *** empty log message ***
81
*
82
* Revision 1.1  2006/06/02 10:50:18  jaume
83
* *** empty log message ***
84
*
85
*
86
*/
87
package org.gvsig.app.gui.preferencespage;
88

  
89
import java.util.prefs.Preferences;
90

  
91
import javax.swing.ImageIcon;
92
import javax.swing.JCheckBox;
93
import javax.swing.JLabel;
94
import javax.swing.JPanel;
95
import javax.swing.JTextField;
96

  
97
import org.gvsig.andami.IconThemeHelper;
98
import org.gvsig.andami.PluginServices;
99
import org.gvsig.andami.preferences.AbstractPreferencePage;
100
import org.gvsig.andami.preferences.StoreException;
101
import org.gvsig.andami.ui.mdiManager.IWindow;
102
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
103
import org.gvsig.fmap.mapcontrol.MapControl;
104
import org.gvsig.fmap.mapcontrol.tools.grid.Grid;
105

  
106

  
107
public class GridPage extends AbstractPreferencePage {
108
	public static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" );
109
	private org.gvsig.fmap.mapcontrol.MapControl mapControl;
110
	private JCheckBox chkShowGrid;
111
	private JCheckBox chkAdjustGrid;
112
	private JTextField txtDistanceX;
113
	private JTextField txtDistanceY;
114
	private JLabel lblUnits=new JLabel();
115
	private ImageIcon icon;
116

  
117
	public GridPage() {
118
		super();
119
		
120
		icon = IconThemeHelper.getImageIcon("grid-preferences");
121
		
122
		chkShowGrid=new JCheckBox(PluginServices.getText(this,"mostrar_rejilla"));
123
		addComponent(chkShowGrid);
124
		chkAdjustGrid=new JCheckBox(PluginServices.getText(this,"ajustar_rejilla"));
125
		addComponent(chkAdjustGrid);
126
		addComponent(lblUnits);
127

  
128
		// distance x
129
		addComponent(PluginServices.getText(this, "distance_x") + ":",
130
			txtDistanceX = new JTextField("", 15));
131
		// distance y
132
		addComponent(PluginServices.getText(this, "distance_y") + ":",
133
			txtDistanceY = new JTextField("", 15));
134
		setParentID(ViewPage.id);
135

  
136
	}
137

  
138
	public void initializeValues() {
139
		boolean showGrid = prefs.getBoolean("grid.showgrid",Grid.DefaultShowGrid);
140
		boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",Grid.DefaultAdjustGrid);
141

  
142
		double dx = prefs.getDouble("grid.distancex",Grid.DefaultGridSizeX);
143
		double dy = prefs.getDouble("grid.distancey",Grid.DefaultGridSizeY);
144

  
145
		Grid.SHOWGRID=showGrid;
146
		Grid.ADJUSTGRID=adjustGrid;
147
		Grid.GRIDSIZEX=dx;
148
		Grid.GRIDSIZEY=dy;
149

  
150
//		setGridVisibility(showGrid);
151
//		setAdjustGrid(adjustGrid);
152
//		cadgrid.setGridSizeX(dx);
153
//		cadgrid.setGridSizeY(dy);
154
//		cta=CADExtension.getCADToolAdapter();
155
//		cta.initializeGrid();
156
//		ViewPort vp=cta.getMapControl().getViewPort();
157
//		boolean showGrid = prefs.getBoolean("grid.showgrid",cta.getGrid().isShowGrid());
158
//		boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",cta.getGrid().isAdjustGrid());
159
//
160
//		double dx = prefs.getDouble("grid.distancex",cta.getGrid().getGridSizeX());
161
//		double dy = prefs.getDouble("grid.distancey",cta.getGrid().getGridSizeY());
162
//		CADGrid cg=cta.getGrid();
163
		chkShowGrid.setSelected(showGrid);
164
		chkAdjustGrid.setSelected(adjustGrid);
165
		txtDistanceX.setText(String.valueOf(dx));
166
		txtDistanceY.setText(String.valueOf(dy));
167
//		lblUnits.setText(PluginServices.getText(this,"Unidades")+ "           "+PluginServices.getText(this,MapContext.getDistanceNames()[vp.getDistanceUnits()]));
168

  
169
//		cta.setGridVisibility(showGrid);
170
//		cta.setAdjustGrid(adjustGrid);
171
//		cta.getGrid().setGridSizeX(dx);
172
//		cta.getGrid().setGridSizeY(dy);
173

  
174
	}
175

  
176
	public String getID() {
177
		return this.getClass().getName();
178
	}
179

  
180
	public String getTitle() {
181
		return PluginServices.getText(this, "Grid");
182
	}
183

  
184
	public JPanel getPanel() {
185
		return this;
186
	}
187

  
188
	public void storeValues() throws StoreException {
189
		boolean showGrid;
190
		boolean adjustGrid;
191
		double dx;
192
		double dy;
193

  
194
			showGrid=chkShowGrid.isSelected();
195
			adjustGrid=chkAdjustGrid.isSelected();
196
		try{
197
			dx=Double.parseDouble(txtDistanceX.getText());
198
			dy=Double.parseDouble(txtDistanceY.getText());
199
		}catch (Exception e) {
200
			throw new StoreException(PluginServices.getText(this,"distancia_malla_incorrecta"));
201
		}
202
		prefs.putBoolean("grid.showgrid",showGrid);
203
		prefs.putBoolean("grid.adjustgrid",adjustGrid);
204
		prefs.putDouble("grid.distancex", dx);
205
		prefs.putDouble("grid.distancey", dy);
206

  
207
		Grid.SHOWGRID=showGrid;
208
		Grid.ADJUSTGRID=adjustGrid;
209
		Grid.GRIDSIZEX=dx;
210
		Grid.GRIDSIZEY=dy;
211

  
212
		IWindow window=PluginServices.getMDIManager().getActiveWindow();
213
		if (window instanceof DefaultViewPanel){
214
			MapControl mc=((DefaultViewPanel)window).getMapControl();
215
			Grid cadGrid=mc.getGrid();
216
			cadGrid.setShowGrid(showGrid);
217
			cadGrid.setAdjustGrid(adjustGrid);
218
			cadGrid.setGridSizeX(dx);
219
			cadGrid.setGridSizeY(dy);
220
		}
221

  
222
	}
223

  
224
	public void initializeDefaults() {
225
		chkShowGrid.setSelected(Grid.DefaultShowGrid);
226
		chkAdjustGrid.setSelected(Grid.DefaultAdjustGrid);
227
//		ViewPort vp=cta.getMapControl().getViewPort();
228
//		lblUnits.setText(PluginServices.getText(this,"Unidades")+ "           "+PluginServices.getText(this,MapContext.getDistanceNames()[vp.getDistanceUnits()]));
229
		txtDistanceX.setText(String.valueOf(Grid.DefaultGridSizeX));
230
		txtDistanceY.setText(String.valueOf(Grid.DefaultGridSizeY));
231
	}
232

  
233
	public ImageIcon getIcon() {
234
		return icon;
235
	}
236

  
237
	public boolean isValueChanged() {
238
		return super.hasChanged();
239
	}
240

  
241
	public void setChangesApplied() {
242
		setChanged(false);
243
	}
244
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/gui/GeneralViewPropertiesPage.java
42 42
import org.gvsig.tools.i18n.I18nManager;
43 43

  
44 44
public class GeneralViewPropertiesPage extends JPanel implements PropertiesPage {
45
    
45

  
46 46
    public static final int FIXED_WIDTH = 300;
47
    
47

  
48 48
    private javax.swing.JLabel jLabelName = null;
49 49
    private javax.swing.JTextField txtName = null;
50 50
    private javax.swing.JLabel jLabelDate = null;
......
60 60
    private javax.swing.JLabel jLabelColor = null;
61 61
    private javax.swing.JLabel jLabelComments = null;
62 62
    private javax.swing.JPanel lblColor = null;
63
    
63

  
64 64
    private JCheckBox setAsDefCrsChk = null;
65 65

  
66 66
    private Color backColor = null;
......
71 71
    protected CRSSelectPanel jPanelProj = null;
72 72
    private boolean isAcceppted = false;
73 73
    private JComboBox cmbDistanceArea = null;
74
    
74

  
75 75
    public GeneralViewPropertiesPage(ViewDocument view) {
76 76
        this.view = view;
77 77
        initComponents();
......
103 103
            }
104 104
        }
105 105

  
106
        view.setName(name);
107
        view.setCreationDate(txtDate.getText());
108
        view.setOwner(txtOwner.getText());
109
        view.setComment(txtComments.getText());
110
        view.getMapContext().getViewPort()
111
            .setMapUnits(cmbMapUnits.getSelectedIndex());
112
        view.getMapContext().getViewPort()
113
            .setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
114
        view.getMapContext().getViewPort()
115
            .setDistanceArea(cmbDistanceArea.getSelectedIndex());
116
        view.setBackColor(backColor);
106
        //FIXME: Parche provisional para permitir guardar otras propiedades de la vista en edici?n
107
        if (!view.isLocked()) {
108
            view.setName(name);
109
            view.setCreationDate(txtDate.getText());
110
            view.setOwner(txtOwner.getText());
111
            view.setComment(txtComments.getText());
112
            view.getMapContext().getViewPort()
113
                .setMapUnits(cmbMapUnits.getSelectedIndex());
114
            view.getMapContext().getViewPort()
115
                .setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
116
            view.getMapContext().getViewPort()
117
                .setDistanceArea(cmbDistanceArea.getSelectedIndex());
118
            view.setBackColor(backColor);
117 119

  
118
        // Select the projection
119
        if (jPanelProj.isOkPressed()) {
120
            if (!jPanelProj.getCurProj().isProjected()) {
121
                getCmbMapUnits().setSelectedItem(
122
                    Messages.getText("Grados"));
123
                getCmbMapUnits().setEnabled(false);
124
            } else {
125
                if (getCmbMapUnits().getSelectedItem().equals(
126
                    Messages.getText("Grados"))) {
127
                    getCmbMapUnits().setSelectedIndex(1);
120
            // Select the projection
121
            if (jPanelProj.isOkPressed()) {
122
                if (!jPanelProj.getCurProj().isProjected()) {
123
                    getCmbMapUnits()
124
                        .setSelectedItem(Messages.getText("Grados"));
125
                    getCmbMapUnits().setEnabled(false);
126
                } else {
127
                    if (getCmbMapUnits().getSelectedItem().equals(
128
                        Messages.getText("Grados"))) {
129
                        getCmbMapUnits().setSelectedIndex(1);
130
                    }
131
                    getCmbMapUnits().setEnabled(true);
128 132
                }
129
                getCmbMapUnits().setEnabled(true);
133
                view.setProjection(jPanelProj.getCurProj());
134
                if (getSetAsDefaultCrsCheckbox().isSelected()) {
135
                    setAppDefaultCRS(jPanelProj.getCurProj().getAbrev());
136
                }
130 137
            }
131
            view.setProjection(jPanelProj.getCurProj());
132
            if (getSetAsDefaultCrsCheckbox().isSelected()) {
133
                setAppDefaultCRS(jPanelProj.getCurProj().getAbrev());
134
            }
135 138
        }
139

  
136 140
        return true;
137 141
    }
138 142

  
......
178 182
        JPanel secondHalfPanel = new JPanel(new GridBagLayout());
179 183

  
180 184
        GridBagConstraints c2 = new GridBagConstraints();
181
        
185

  
182 186
        c2.fill = GridBagConstraints.BOTH;
183 187
        c2.weightx = 1.0;   //request any extra hor space
184
        c2.gridx = 0;      
185
        c2.gridwidth = 1;  
186
        c2.gridy = 0;      
187
        
188
        c2.gridx = 0;
189
        c2.gridwidth = 1;
190
        c2.gridy = 0;
191

  
188 192
        JPanel auxPanel = new JPanel(new GridLayout(1,2));
189 193
        auxPanel.add(getLblColor(secondHalfPanel.getBackground()));
190 194
        auxPanel.add(new JLabel(""));
191 195
        secondHalfPanel.add(auxPanel, c2);
192
        
196

  
193 197
        c2.fill = GridBagConstraints.NONE;
194
        c2.weightx = 0.0;  
195
        c2.gridx = 1;      
198
        c2.weightx = 0.0;
199
        c2.gridx = 1;
196 200
        secondHalfPanel.add(getBtnColor(), c2);
197 201

  
198 202
        colorPanel.add(secondHalfPanel);
199
        
203

  
200 204
        c.gridx = 0;
201 205
        c.gridwidth = 2;
202 206
        c.gridy++;
......
211 215
        c.weightx = 1.0d;
212 216
        c.fill = GridBagConstraints.HORIZONTAL;
213 217
        add(getJPanelProj(), c);
214
        
218

  
215 219
        // ============ set current as app default CRS
216 220
        c.anchor = GridBagConstraints.CENTER;
217 221
        c.gridy++;
......
219 223
        auxp.add(getSetAsDefaultCrsCheckbox(), BorderLayout.CENTER);
220 224
        add(auxp, c);
221 225
        // =============================
222
        
226

  
223 227
        // some extra space
224 228
        addRow(c, new JLabel(" "), new JLabel(" "));
225 229

  
......
238 242
    }
239 243

  
240 244

  
241

  
242

  
243 245
    /**
244 246
     * @return
245 247
     */
246 248
    private JCheckBox getSetAsDefaultCrsCheckbox() {
247
        
249

  
248 250
        if (setAsDefCrsChk == null) {
249 251
            setAsDefCrsChk = new JCheckBox(Messages.getText(
250 252
                "_Set_this_CRS_as_app_default"));
......
252 254
        }
253 255
        return setAsDefCrsChk;
254 256
    }
255
    
256 257

  
258

  
257 259
    private String getAppDefaultCRS() {
258 260
        ProjectPreferences pp = new ProjectPreferences();
259 261
        IProjection curr_def = pp.getDefaultProjection();
260 262
        return curr_def.getAbrev();
261 263
    }
262
    
264

  
263 265
    private void setAppDefaultCRS(String abbrev) {
264 266
        IProjection proj = CRSFactory.getCRS(abbrev);
265 267
        ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences();
266 268
        projectPreferences.setDefaultProjection(proj);
267 269
    }
268
    
270

  
269 271
    private void updateSetAsDefaultCRSChk() {
270
        
272

  
271 273
        IProjection view_proj = this.jPanelProj.getCurProj();
272 274
        String view_abbrev = view_proj.getAbrev();
273
        
275

  
274 276
        String curr_app_crs_def = getAppDefaultCRS();
275 277
        if (view_abbrev.compareToIgnoreCase(curr_app_crs_def) == 0) {
276 278
            // same as curr default
......
294 296
        c.gridx = 1;
295 297
        add(text, c);
296 298
    }
297
    
298 299

  
299 300

  
301

  
300 302
    /**
301 303
     * This method initializes jLabel
302
     * 
304
     *
303 305
     * @return javax.swing.JLabel
304 306
     */
305 307
    private javax.swing.JLabel getJLabelName() {
......
313 315

  
314 316
    /**
315 317
     * This method initializes txtName
316
     * 
318
     *
317 319
     * @return javax.swing.JTextField
318 320
     */
319 321
    private javax.swing.JTextField getTxtName() {
......
326 328

  
327 329
    /**
328 330
     * This method initializes jLabel1
329
     * 
331
     *
330 332
     * @return javax.swing.JLabel
331 333
     */
332 334
    private javax.swing.JLabel getJLabelDate() {
......
340 342

  
341 343
    /**
342 344
     * This method initializes txtDate
343
     * 
345
     *
344 346
     * @return javax.swing.JTextField
345 347
     */
346 348
    private javax.swing.JTextField getTxtDate() {
......
355 357

  
356 358
    /**
357 359
     * This method initializes jLabel2
358
     * 
360
     *
359 361
     * @return javax.swing.JLabel
360 362
     */
361 363
    private javax.swing.JLabel getJLabelOwner() {
......
369 371

  
370 372
    /**
371 373
     * This method initializes txtOwner
372
     * 
374
     *
373 375
     * @return javax.swing.JTextField
374 376
     */
375 377
    private javax.swing.JTextField getTxtOwner() {
......
382 384

  
383 385
    /**
384 386
     * This method initializes jLabel4
385
     * 
387
     *
386 388
     * @return javax.swing.JLabel
387 389
     */
388 390
    private javax.swing.JLabel getJLabelMapUnits() {
......
396 398

  
397 399
    /**
398 400
     * This method initializes cmbMapUnits
399
     * 
401
     *
400 402
     * @return javax.swing.JComboBox
401 403
     */
402 404
    private javax.swing.JComboBox getCmbMapUnits() {
......
426 428

  
427 429
    /**
428 430
     * This method initializes jLabel5
429
     * 
431
     *
430 432
     * @return javax.swing.JLabel
431 433
     */
432 434
    private javax.swing.JLabel getJLabelDistanceUnits() {
......
440 442

  
441 443
    /**
442 444
     * This method initializes jLabel6
443
     * 
445
     *
444 446
     * @return javax.swing.JLabel
445 447
     */
446 448
    private javax.swing.JLabel getJLabelAreaUnits() {
......
454 456

  
455 457
    /**
456 458
     * This method initializes cmbDistanceUnits
457
     * 
459
     *
458 460
     * @return javax.swing.JComboBox
459 461
     */
460 462
    private javax.swing.JComboBox getCmbDistanceUnits() {
......
471 473

  
472 474
    /**
473 475
     * This method initializes jLabel6
474
     * 
476
     *
475 477
     * @return javax.swing.JLabel
476 478
     */
477 479
    private javax.swing.JLabel getJLabelComments() {
......
489 491

  
490 492
    /**
491 493
     * This method initializes txtComments
492
     * 
494
     *
493 495
     * @return javax.swing.JTextArea
494 496
     */
495 497
    private javax.swing.JTextArea getTxtComments() {
......
504 506

  
505 507
    /**
506 508
     * This method initializes jLabel7
507
     * 
509
     *
508 510
     * @return javax.swing.JLabel
509 511
     */
510 512
    private javax.swing.JLabel getJLabelColor() {
......
519 521

  
520 522
    /**
521 523
     * This method initializes lblColor
522
     * 
524
     *
523 525
     * @return javax.swing.JLabel
524 526
     */
525 527
    private javax.swing.JPanel getLblColor(Color surround_color) {
......
541 543

  
542 544
    /**
543 545
     * This method initializes btnColor
544
     * 
546
     *
545 547
     * @return javax.swing.JButton
546 548
     */
547 549
    private JButton getBtnColor() {
......
574 576

  
575 577
    /**
576 578
     * This method initializes jScrollPane
577
     * 
579
     *
578 580
     * @return javax.swing.JScrollPane
579 581
     */
580 582
    private javax.swing.JScrollPane getJScrollPaneComments() {
......
591 593

  
592 594
    /**
593 595
     * This method initializes jPanel4
594
     * 
596
     *
595 597
     * @return javax.swing.JPanel
596 598
     */
597 599
    private CRSSelectPanel getJPanelProj() {
......
606 608
                    	if(numberOfLayers > 0) {
607 609
                    		warningViewProjectionChange();
608 610
                    	}
609
                    	
611

  
610 612
                        if (!jPanelProj.getCurProj().isProjected()) {
611 613
                            getCmbMapUnits().setSelectedItem(
612 614
                                PluginServices
......
627 629
        }
628 630
        return jPanelProj;
629 631
    }
630
    
632

  
631 633
    private void warningViewProjectionChange() {
632 634
    	JOptionPane.showMessageDialog(
633 635
    			(Component)PluginServices.getMainFrame(),
......
648 650

  
649 651
    /**
650 652
     * This method initializes jComboBox
651
     * 
653
     *
652 654
     * @return javax.swing.JComboBox
653 655
     */
654 656
    private JComboBox getCmbDistanceArea() {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/gui/ProjectWindow.java
82 82
/**
83 83
 * Clase principal del proyecto donde se puede operar para crear cualquier tipo
84 84
 * de documento.
85
 * 
85
 *
86 86
 * @author Vicente Caballero Navarro
87 87
 * @author gvSIG team
88 88
 */
......
127 127

  
128 128
    /**
129 129
     * This is the default constructor
130
     * 
130
     *
131 131
     * @param project
132 132
     *            Extension
133 133
     */
......
142 142

  
143 143
    /**
144 144
     * Asigna el proyecto a la ventana
145
     * 
145
     *
146 146
     * @param project
147 147
     *            Proyecto con el que se operar? a trav?s de este di?logo
148 148
     */
......
200 200
    /**
201 201
     * Devuelve el nombre del tipo de documento activo (el mismo que
202 202
     * ProjectDocumentFactory.getRegisterName)
203
     * 
204
     * 
203
     *
204
     *
205 205
     * @return
206 206
     */
207 207

  
......
304 304

  
305 305
    /**
306 306
     * Crea un nuevo project element
307
     * 
307
     *
308 308
     * @throws Exception
309 309
     *             DOCUMENT ME!
310 310
     */
......
359 359
        List<Document> documents = project.getDocuments(doctype);
360 360
        Document doc = documents.get(index);
361 361

  
362
        if (doc.isLocked()) {
363
            JOptionPane.showMessageDialog(this, PluginServices.getText(this,
364
                "locked_element_it_cannot_be_renamed"));
365
            return;
366
        }
367

  
368 362
        JOptionPane pane = new JOptionPane();
369 363
        pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
370 364
        pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
......
455 449
        String doctype = getDocumentSelected();
456 450
        List<Document> documents = project.getDocuments(doctype);
457 451
        Document doc = documents.get(index);
458
        if (doc.isLocked()) {
459
            JOptionPane.showMessageDialog(this,
460
                PluginServices.getText(this, "locked_element"));
461
            return;
462
        }
463 452
        dlg = doc.getFactory().getPropertiesWindow(doc);
464 453
        PluginServices.getMDIManager().addWindow(dlg);
465 454

  
......
470 459

  
471 460
    /**
472 461
     * This method initializes jPanel
473
     * 
462
     *
474 463
     * @return JPanel
475 464
     */
476 465
    private JComponent getDocumentTypesPanel() {
......
508 497

  
509 498
    /**
510 499
     * This method initializes btnVistas
511
     * 
500
     *
512 501
     * @return JRadioButton
513 502
     */
514 503
    private JRadioButton[] getBtnDocumentTypes() {
......
548 537

  
549 538
    /**
550 539
     * This method initializes jPanel1
551
     * 
540
     *
552 541
     * @return JPanel
553 542
     */
554 543
    private JPanel getDocumentsPanel() {
......
586 575

  
587 576
    /**
588 577
     * This method initializes lstDocs
589
     * 
578
     *
590 579
     * @return JList
591 580
     */
592 581
    private JList getDocumentsList() {
......
659 648

  
660 649
    /**
661 650
     * This method initializes jPanel2
662
     * 
651
     *
663 652
     * @return JPanel
664 653
     */
665 654
    private JPanel getDocumentButtonsPanel() {
......
683 672

  
684 673
    /**
685 674
     * This method initializes btnNuevo
686
     * 
675
     *
687 676
     * @return JButton
688 677
     */
689 678
    private JButton getBtnNuevo() {
......
710 699

  
711 700
    /**
712 701
     * This method initializes btnPropiedades
713
     * 
702
     *
714 703
     * @return JButton
715 704
     */
716 705
    private JButton getBtnPropiedades() {
......
735 724

  
736 725
    /**
737 726
     * This method initializes btnAbrir
738
     * 
727
     *
739 728
     * @return JButton
740 729
     */
741 730
    private JButton getBtnAbrir() {
......
758 747

  
759 748
    /**
760 749
     * This method initializes btnBorrar
761
     * 
750
     *
762 751
     * @return JButton
763 752
     */
764 753
    private JButton getBtnBorrar() {
......
781 770

  
782 771
    /**
783 772
     * This method initializes btnRenombrar
784
     * 
773
     *
785 774
     * @return JButton
786 775
     */
787 776
    private JButton getBtnRenombrar() {
......
804 793

  
805 794
    /**
806 795
     * This method initializes jPanel3
807
     * 
796
     *
808 797
     * @return JPanel
809 798
     */
810 799
    private JPanel getPropertiesPanel() {
......
865 854

  
866 855
    /**
867 856
     * This method initializes jLabel
868
     * 
857
     *
869 858
     * @return JLabel
870 859
     */
871 860
    private JLabel getJLabel() {
......
879 868

  
880 869
    /**
881 870
     * This method initializes lblNombreSesion
882
     * 
871
     *
883 872
     * @return JLabel
884 873
     */
885 874
    private JLabel getLblNombreSesion() {
......
895 884

  
896 885
    /**
897 886
     * This method initializes jLabel1
898
     * 
887
     *
899 888
     * @return JLabel
900 889
     */
901 890
    private JLabel getJLabel1() {
......
909 898

  
910 899
    /**
911 900
     * This method initializes lblGuardado
912
     * 
901
     *
913 902
     * @return JLabel
914 903
     */
915 904
    private JLabel getLblGuardado() {
......
924 913

  
925 914
    /**
926 915
     * This method initializes jLabel2
927
     * 
916
     *
928 917
     * @return JLabel
929 918
     */
930 919
    private JLabel getJLabel2() {
......
939 928

  
940 929
    /**
941 930
     * This method initializes lblFecha
942
     * 
931
     *
943 932
     * @return JLabel
944 933
     */
945 934
    private JLabel getLblFecha() {
......
954 943

  
955 944
    /**
956 945
     * This method initializes btnImportar
957
     * 
946
     *
958 947
     * @return JButton
959 948
     */
960 949
    private JButton getBtnImportar() {
......
971 960

  
972 961
    /**
973 962
     * This method initializes btnExportar
974
     * 
963
     *
975 964
     * @return JButton
976 965
     */
977 966
    private JButton getBtnExportar() {
......
988 977

  
989 978
    /**
990 979
     * This method initializes btnEditar
991
     * 
980
     *
992 981
     * @return JButton
993 982
     */
994 983
    private JButton getBtnEditar() {
......
1006 995
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
1007 996
                    WindowManager winmgr = ToolsSwingLocator.getWindowManager();
1008 997
                    winmgr.showWindow(
1009
                            new ProjectProperties(project), 
1010
                            i18nManager.getTranslation("project_properties"), 
998
                            new ProjectProperties(project),
999
                            i18nManager.getTranslation("project_properties"),
1011 1000
                            WindowManager.MODE.WINDOW
1012 1001
                    );
1013 1002
                    refreshProperties();
......
1020 1009

  
1021 1010
    /**
1022 1011
     * This method initializes jScrollPane
1023
     * 
1012
     *
1024 1013
     * @return JScrollPane
1025 1014
     */
1026 1015
    private JScrollPane getDocumentsScrollPane() {
......
1051 1040
     * ViewInfo object in a later time. <strong>Use
1052 1041
     * PluginServices.getMDIManager().getViewInfo(view) to retrieve the ViewInfo
1053 1042
     * object at any time after the creation of the object.
1054
     * 
1043
     *
1055 1044
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
1056 1045
     */
1057 1046
    public WindowInfo getWindowInfo() {
......
1087 1076

  
1088 1077
    /**
1089 1078
     * This method initializes jPanel4
1090
     * 
1079
     *
1091 1080
     * @return JPanel
1092 1081
     */
1093 1082
    private JPanel getProjectsButtonPanel() {
......
1141 1130
    @Override
1142 1131
    public void setLocale(Locale locale) {
1143 1132
        super.setLocale(locale);
1144
        
1133

  
1145 1134
        I18nManager i18nManager = ToolsLocator.getI18nManager();
1146 1135

  
1147 1136
        btnNuevo.setText(i18nManager.getTranslation( "nuevo"));
1148
        btnPropiedades.setText(i18nManager.getTranslation("propiedades")); 
1137
        btnPropiedades.setText(i18nManager.getTranslation("propiedades"));
1149 1138
        btnAbrir.setText(i18nManager.getTranslation("abrir"));
1150 1139
        btnBorrar.setText(i18nManager.getTranslation("borrar"));
1151 1140
        btnRenombrar.setText(i18nManager.getTranslation("renombrar"));
......
1153 1142
        jLabel.setText(i18nManager.getTranslation("nombre_sesion") + ":");
1154 1143
        jLabel1.setText(i18nManager.getTranslation("guardado") + ":");
1155 1144
        jLabel2.setText(i18nManager.getTranslation("creation_date") + ":");
1156
        
1145

  
1157 1146
        // btnImportar.setText(i18nManager.getTranslation("importar"));
1158 1147
        // btnExportar.setText(i18nManager.getTranslation("exportar"));
1159 1148
        btnEditar.setText(i18nManager.getTranslation("propiedades"));
1160
        
1149

  
1161 1150
        m_viewInfo.setTitle(i18nManager.getTranslation("_Project_manager"));
1162 1151

  
1163 1152
        TitledBorder border = null;
1164
        
1153

  
1165 1154
        border = (TitledBorder) propertiesPanel.getBorder();
1166 1155
        border.setTitle(i18nManager.getTranslation("propiedades_sesion"));
1167 1156

  
......
1171 1160
        border = (TitledBorder) documentsPanel.getBorder();
1172 1161
        border.setTitle(i18nManager.getTranslation("documentos_existentes"));
1173 1162

  
1174
        refreshList();        
1163
        refreshList();
1175 1164
    }
1176 1165

  
1177
    
1166

  
1178 1167
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/clipboard/CopyFeaturesToClipboardExtension.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.extension.clipboard;
25

  
26
import javax.swing.JOptionPane;
27

  
28
import org.slf4j.Logger;
29
import org.slf4j.LoggerFactory;
30

  
31
import org.gvsig.andami.IconThemeHelper;
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.andami.plugins.Extension;
34
import org.gvsig.andami.ui.mdiManager.IWindow;
35
import org.gvsig.app.ApplicationLocator;
36
import org.gvsig.app.extension.clipboard.util.FeatureTextUtils;
37
import org.gvsig.app.project.documents.view.gui.IView;
38
import org.gvsig.fmap.dal.exception.DataException;
39
import org.gvsig.fmap.dal.feature.FeatureSelection;
40
import org.gvsig.fmap.dal.feature.FeatureStore;
41
import org.gvsig.fmap.mapcontext.layers.FLayer;
42
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
43
import org.gvsig.i18n.Messages;
44

  
45

  
46
public class CopyFeaturesToClipboardExtension extends Extension {
47

  
48
    private static Logger logger = LoggerFactory.getLogger(
49
    		CopyFeaturesToClipboardExtension.class);
50

  
51
	public void initialize() {
52

  
53
		IconThemeHelper.registerIcon("action", "layer-modify-clipboard-copy", this);
54
	}
55

  
56
	public void execute(String actionCommand) {
57

  
58
		if (actionCommand.compareToIgnoreCase("layer-modify-clipboard-copy") != 0) {
59
			return;
60
		}
61

  
62
		IWindow actw = actWin();
63

  
64
		if (actw instanceof IView) {
65

  
66
			IView vw = (IView) actw;
67
			FLayer[] act_lyr = vw.getMapControl().getMapContext().getLayers().getActives();
68
			if (act_lyr == null || act_lyr.length != 1
69
					|| !(act_lyr[0] instanceof FLyrVect)) {
70

  
71
			} else {
72

  
73
				int usr_opt = JOptionPane.showConfirmDialog(
74
						ApplicationLocator.getManager().getRootComponent(),
75
						Messages.getText("_Include_alphanumeric_attributes_Question"),
76
						Messages.getText("_Copy_selected_features_to_clipboard"),
77
						JOptionPane.YES_NO_CANCEL_OPTION,
78
						JOptionPane.QUESTION_MESSAGE);
79

  
80

  
81
				if (usr_opt == JOptionPane.CANCEL_OPTION) {
82
					return;
83
				}
84

  
85
				FLyrVect vect = (FLyrVect) act_lyr[0];
86
				FeatureSelection sele = null;
87
				FeatureStore fsto = null;
88
				try {
89
					fsto = vect.getFeatureStore();
90
					sele = (FeatureSelection) fsto.getSelection();
91

  
92
					StringBuilder strb = FeatureTextUtils.toString(
93
							sele, fsto.getDefaultFeatureType(),
94
							usr_opt == JOptionPane.YES_OPTION);
95
					/*
96
					 * Put selected features in clipboard.
97
					 */
98
					PluginServices.putInClipboard(strb.toString());
99

  
100
					JOptionPane.showMessageDialog(
101
							ApplicationLocator.getManager().getRootComponent(),
102
							Messages.getText("_Number_of_features_copied_to_clipboard")
103
							+ ":   " + sele.getSize() + "    ",
104
							Messages.getText("_Copy_selected_features_to_clipboard"),
105
							JOptionPane.INFORMATION_MESSAGE);
106

  
107
				} catch (DataException e) {
108
					logger.error("While getting store and selection. ", e);
109
				}
110
			}
111
		}
112

  
113
	}
114

  
115
	public boolean isEnabled() {
116

  
117
		/*
118
		 * It's enabled if there is exactly one vector layer in the active view
119
		 * and it has a selection
120
		 */
121

  
122
		IWindow actw = actWin();
123

  
124
		if (actw instanceof IView) {
125

  
126
			IView vw = (IView) actw;
127
			FLayer[] act_lyr = vw.getMapControl().getMapContext().getLayers().getActives();
128
			if (act_lyr == null || act_lyr.length != 1
129
					|| !(act_lyr[0] instanceof FLyrVect)) {
130
				return false;
131

  
132
			} else {
133
				FLyrVect vect = (FLyrVect) act_lyr[0];
134
				if (!vect.isAvailable()) {
135
				    /*
136
				     * This can happen when opening a persisted project
137
				     * and there is a "slow" layer (GeoDB)
138
				     */
139
				    return false;
140
				}
141
				FeatureSelection sele = null;
142
				long sele_count = 0;
143
				try {
144
					sele = (FeatureSelection) vect.getFeatureStore().getSelection();
145
					sele_count = sele.getSize();
146
				} catch (DataException e) {
147
					logger.error("While getting store. ", e);
148
					return false;
149
				}
150
				return sele_count > 0;
151
			}
152

  
153
		} else {
154
			return false;
155
		}
156
	}
157

  
158
	public boolean isVisible() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff