Revision 35021

View differences:

tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/ApplicationManager.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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
package org.gvsig.app;
29

  
30
import java.util.List;
31

  
32
import org.cresques.cts.IProjection;
33
import org.gvsig.about.AboutManager;
34
import org.gvsig.andami.iconthemes.IconThemeManager;
35
import org.gvsig.andami.ui.mdiManager.MDIManager;
36
import org.gvsig.app.extension.Version;
37
import org.gvsig.app.gui.WizardPanel;
38
import org.gvsig.app.prepareAction.PrepareContext;
39
import org.gvsig.app.prepareAction.PrepareContextView;
40
import org.gvsig.app.prepareAction.PrepareDataStore;
41
import org.gvsig.app.prepareAction.PrepareDataStoreParameters;
42
import org.gvsig.app.prepareAction.PrepareLayer;
43
import org.gvsig.app.project.Project;
44
import org.gvsig.app.project.ProjectManager;
45
import org.gvsig.fmap.dal.DataManager;
46
import org.gvsig.fmap.dal.DataStore;
47
import org.gvsig.fmap.dal.DataStoreParameters;
48
import org.gvsig.fmap.geom.GeometryManager;
49
import org.gvsig.fmap.mapcontext.MapContextManager;
50
import org.gvsig.fmap.mapcontext.layers.FLayer;
51
import org.gvsig.gui.IColorTablesFactory;
52
import org.gvsig.tools.dispose.DisposableManager;
53
import org.gvsig.tools.dynobject.DynObjectManager;
54
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
55
import org.gvsig.tools.persistence.PersistenceManager;
56

  
57

  
58
public interface ApplicationManager {
59

  
60
	Version getVersion() ;
61

  
62
	PreferencesNode getPreferences();
63
	
64
	PreferencesNode getPreferences(String nodeName);
65
	
66
	Project getCurrentProject();
67
	
68
	DataManager getDataManager();
69
	
70
	ProjectManager getProjectManager();
71
	
72
	MDIManager getUIManager();
73
	
74
	GeometryManager getGeometryManager();
75
	
76
	PersistenceManager getPersistenceManager();
77
	
78
	DisposableManager getDisposableManager() ;
79

  
80
	DynObjectManager getDynObjectManager() ;
81

  
82
	ExtensionPointManager getExtensionPointManager();
83

  
84
	MapContextManager getMapContextManager();
85
	
86
	IProjection getCRS(String code);
87
	
88
	IconThemeManager getIconThemeManager();
89
	
90
	String[] getArguments();
91
	
92
	String getArgument(String name);
93
	
94
	String getFromClipboard();
95
	
96
	void putInClipboard(String data) ;
97

  
98
	
99
	void registerAddTableWizard(String name, String description,
100
			Class<? extends WizardPanel> wpClass);
101

  
102
	List<WizardPanel> getWizardPanels() throws Exception;
103

  
104

  
105

  
106
	void registerPrepareOpenDataStore(PrepareDataStore action);
107
	void registerPrepareOpenDataStoreParameters(	PrepareDataStoreParameters action);
108
	void registerPrepareOpenLayer(PrepareLayer action);
109

  
110
	DataStore pepareOpenDataSource(DataStore store,
111
			PrepareContext context)
112
			throws Exception;
113

  
114
	DataStoreParameters prepareOpenDataStoreParameters(
115
			DataStoreParameters storeParameters, PrepareContext context)
116
			throws Exception;
117

  
118
	FLayer prepareOpenLayer(FLayer layer,
119
			PrepareContextView context)
120
			throws Exception;
121
	
122
	public AboutManager getAbout();
123
	
124
//	void registerPrepareOpenAction(PrepareAction action);
125
//
126
//	Object executePrepareOpenAction(PrepareContext context, Object data)	throws Exception;
127

  
128
	public IColorTablesFactory getColorTablesFactory();
129
	
130
	public void registerColorTablesFactory(IColorTablesFactory factory);
131
	
132
}
0 133

  
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/sqlQueryValidation/SQLQueryValidation.java
1
package org.gvsig.app.sqlQueryValidation;
2

  
3
import java.io.ByteArrayInputStream;
4

  
5
import org.gvsig.andami.PluginServices;
6

  
7
import Zql.ZqlParser;
8

  
9

  
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50

  
51
/**
52
 * Class for validate a complete query or the sentence of a query from WHERE 
53
 *
54
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
55
 */
56
public class SQLQueryValidation {
57
	private String query;
58
	private boolean onlyWhereStatement;
59
	private int[] errorPosition; //[0] -> line, [1] -> column        ( (-1, -1) -> no error ) ( (-2, -2) -> error: query = null)
60
	private String errorMessage;
61
	private String errorPositionAsMessage;
62
	private String token;
63
	private final String preQuery = "SELECT a FROM b WHERE ";
64
	private final int preQueryLenght = preQuery.length();
65
	
66
	/**
67
	 * Default constructor with a parameter
68
	 * 
69
	 * @param _query The query to validate
70
	 * @param _onlyWhereStatement If the query is only the part of WHERE ... in a query
71
	 */
72
	public SQLQueryValidation(String _query, boolean _onlyWhereStatement) {
73
		query = new String(_query);
74
		onlyWhereStatement = _onlyWhereStatement;
75
		
76
		// By default no error position
77
		errorPosition = new int[2];
78
		errorPosition[0] = -1;
79
		errorPosition[1] = -1;
80
		
81
		errorPositionAsMessage = null;
82
		
83
		// By default no error message
84
		errorMessage = null;
85
		
86
		// By default no error symbol
87
		token = null;
88
	}
89
		
90
	/**
91
	 * Validates a query
92
	 * 
93
	 * Returns 'null' if there has been some error
94
	 */
95
	public boolean validateQuery() {
96
		String completeQuery = new String();
97
		
98
		// If the query is null -> error 
99
		if (query == null)	{
100
			errorPosition[0] = -2;
101
			errorPosition[1] = -2;
102
			defineErrorPositionAsMessageAttribute(errorPosition);
103
			errorMessage = new String( PluginServices.getText(null, "queryIsNull"));
104
			
105
			return false;
106
		}
107
		
108
		// If no query itsn't considered as a error
109
		if ((query.compareTo("")) == 0) {
110
			errorPosition[0] = -1;
111
			errorPosition[1] = -1;
112
			defineErrorPositionAsMessageAttribute(errorPosition);
113
			errorMessage = null;
114
			
115
			return true;
116
		}
117

  
118
		// Converts all apostrophes between aphostrophes to double inverted commas ( " )
119
		int index = 0;
120
		boolean is_word = false; // by default isn't a word
121
		String formatted_query = new String();
122
		char c;
123
		
124
		while (index < query.length()) {
125
			c = query.charAt(index);
126
			if (c == '\'') {
127
				if (is_word == false) {
128
					if ((index > 0) && ((query.charAt(index-1) == ' ') || (query.charAt(index-1) == '(')) ) {
129
						is_word = true;
130
					}
131
					
132
					formatted_query += c;
133
				}
134
				else {
135
					if (index == (query.length() -1)) {
136
//						is_word = false;
137
						formatted_query += c;
138
					}
139
					else {
140
						if (((query.charAt(index+1) == ' ') || (query.charAt(index+1) == ')')) ) {
141
							is_word = false;
142
							formatted_query += c;
143
						}
144
						else {
145
							formatted_query += "\""; // Convert ' to "
146
						}
147
					}
148
				}
149
			}
150
			else {
151
				formatted_query += c;
152
			}
153
			
154
			index ++;
155
		}		
156
		
157
		// Converts all ocurrences of the symbol " ( double inverted commas ) to space because Zql doesn't support that symbol
158
		if (onlyWhereStatement)
159
			completeQuery = preQuery + formatted_query.trim().replaceAll("\"", " ");
160
		else
161
			completeQuery = formatted_query.trim().replaceAll("\"", " ");
162

  
163
		if ((completeQuery.length() > 0) && (completeQuery.charAt(completeQuery.length() - 1) != ';'))
164
			completeQuery += ";";
165

  
166
		try {
167
			// Starts the parser
168
			ZqlParser p = new ZqlParser();
169
			p.initParser(new ByteArrayInputStream(completeQuery.getBytes()));
170
	      
171
			// Analyzes the query
172
			p.readStatement();
173
			
174
			// If arrives here -> there has been no errors
175
			errorPosition[0] = -1;
176
			errorPosition[1] = -1;
177
			defineErrorPositionAsMessageAttribute(errorPosition);
178
			errorMessage = null;
179
			return true;
180
		} catch (Exception e) {
181
			// Defines the error message
182
			errorMessage = e.getMessage();
183
			
184
			// Get the token that produced the error
185
			int ini_pos = e.getMessage().indexOf('\"') +1;
186
			token = new String(errorMessage.substring(ini_pos, errorMessage.indexOf('\"', ini_pos)));
187

  
188
			// Get the line an column where the syntax error starts
189
			String line = new String(errorMessage.substring(e.getMessage().indexOf("line"), errorMessage.indexOf(',')));
190
			line = line.substring(line.indexOf(' ')+1, line.length());
191
			
192
			String column = new String(e.getMessage().substring(errorMessage.indexOf("column"), errorMessage.indexOf('.')));
193
			column = column.substring(column.indexOf(' ')+1, column.length());			
194

  
195
			// Get the line an column of the error
196
			errorPosition[0] = Integer.valueOf(line.trim()).intValue();			
197
			errorPosition[1] = Integer.valueOf(column.trim()).intValue();
198
			
199
			if (onlyWhereStatement) {
200
				this.errorPosition[1] -= this.preQueryLenght; // Substract the lenght of the pre-query added
201
			}
202
			
203
			defineErrorPositionAsMessageAttribute(this.errorPosition);
204

  
205
			return false;
206
		}
207
	}
208
	
209
	/**
210
	 * Returns an string with an error message if there has been an error, or 'null' if there hasn't been
211
	 * 
212
	 * @return An string or null
213
	 */
214
	public String getErrorMessage() {
215
		return this.errorMessage;
216
	}
217
	
218
	/**
219
	 * Returns an string with a text describing the (first) position of the error
220
	 * 
221
	 * @return An string or null
222
	 */
223
	public String getErrorPositionAsMessage() {
224
		return this.errorPositionAsMessage;
225
	}
226
	
227
	/**
228
	 * Returns the error position (line, column) or (-1, -1) if there hasn't been any error
229
	 * 
230
	 * @return An array of 2 integer values (first: line, second: column) 
231
	 */
232
	public int[] getErrorPosition() {
233
		return errorPosition;
234
	}
235
	
236
	/**
237
	 * Returns the token where the validator failed
238
	 * 
239
	 * @return An string
240
	 */
241
	public String getTokenThatProducedTheSyntacticError() {
242
		return token;
243
	}
244
	
245
	/**
246
	 * Creates a message with information about the message
247
	 * 
248
	 * @param position An array with 2 elements: (row, column)
249
	 */
250
	private void defineErrorPositionAsMessageAttribute(int position[]) {
251
		// Defines the error message
252
		errorPositionAsMessage = new String( PluginServices.getText(null, "line") + ": " + errorPosition[0] + ", " + PluginServices.getText(null, "column") + ": " + errorPosition[1] );
253
	}
254
}
0 255

  
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/crs/JCRSDynFieldComponent.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
/*
23
 * AUTHORS (In addition to CIT):
24
 * 2010 Institute of New Imaging Technologies (INIT): 
25
 *   http://www.init.uji.es
26
 * Geographic Information research group: 
27
 *   http://www.geoinfo.uji.es
28
 * Universitat Jaume I, Spain
29
 */
30

  
31
/**
32
 * 
33
 */
34
package org.gvsig.app.tools.swing.serv.field.crs;
35

  
36
import java.awt.event.ActionEvent;
37
import java.awt.event.ActionListener;
38

  
39
import javax.swing.JButton;
40
import javax.swing.JComponent;
41

  
42
import org.cresques.cts.IProjection;
43

  
44
import org.gvsig.andami.PluginServices;
45
import org.gvsig.andami.ui.mdiManager.IWindow;
46
import org.gvsig.andami.ui.mdiManager.WindowInfo;
47
import org.gvsig.app.gui.panels.CRSSelectPanel;
48
import org.gvsig.tools.service.ServiceException;
49
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
50
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
51
import org.gvsig.tools.swing.spi.AbstractJDynFieldComponent;
52

  
53
/**
54
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
55
 * 
56
 */
57
public class JCRSDynFieldComponent extends AbstractJDynFieldComponent implements
58
    JDynFieldComponent, IWindow, ActionListener {
59

  
60
    private CRSSelectPanel panel;
61
    private JButton button;
62

  
63
    /**
64
     * @param proj
65
     */
66

  
67
    public JCRSDynFieldComponent(ValueField value)
68
        throws ServiceException {
69
        super(value);
70
    }
71
    /*
72
     * (non-Javadoc)
73
     * 
74
     * @see
75
     * 
76
     * org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent#saveStatus
77
     * ()
78
     */
79
    public void saveStatus() {
80
    	setFieldValue(this.getValue());
81
    }
82

  
83
    /*
84
     * (non-Javadoc)
85
     * 
86
     * @see org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#getValue()
87
     */
88
    public Object getValue() {
89
        return this.getCurProj();
90
    }
91

  
92
    /*
93
     * (non-Javadoc)
94
     * 
95
     * @see
96
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField#setValue(java
97
     * .lang.Object)
98
     */
99
    public void setNullValue() {
100
        this.setCurProj(null);
101
    }
102

  
103
    public void setNonNullValue(Object value) {
104
        if (value instanceof IProjection) {
105
            setCurProj((IProjection) value);
106
        } else {
107
            setNullValue();
108
        }
109
    }
110

  
111
    public void setCurProj(IProjection projection) {
112
        panel.setCurProj(projection);
113
    }
114

  
115
    public IProjection getCurProj() {
116
        return panel.getCurProj();
117
    }
118

  
119
    /*
120
     * (non-Javadoc)
121
     * 
122
     * @see
123
     * org.gvsig.tools.swing.api.dynobject.dynfield.JComponent#getComponent()
124
     */
125
    public Object getComponent() {
126
        return panel;
127
    }
128

  
129
    @Override
130
    protected void setJDynFieldComponentListeners() {
131

  
132
    }
133

  
134
    @Override
135
    protected void afterUI() {
136
        this.panel.getJLabel().setVisible(false);
137
    }
138

  
139
    @Override
140
    protected void initData() {
141
    }
142

  
143
    @Override
144
    protected void initUI() {
145
        IProjection proj = (IProjection) this.getFieldValue();
146
        if (proj==null){
147
            proj = (IProjection) this.getDefaultFieldValue();
148
        }
149
        panel = initJPanelProj(proj);
150
    }
151

  
152
    protected void setReadOnly() {
153
        this.button.setVisible(false);
154
    }
155

  
156
    public void requestFocus() {
157
        this.panel.requestFocus();
158
    }
159

  
160
    public void setEnabled(boolean isEnabled) {
161
        this.panel.setEnabled(isEnabled);
162
    }
163

  
164
    public void actionPerformed(ActionEvent e) {
165
        setValue(panel.getCurProj());
166
    }
167

  
168

  
169
    public WindowInfo getWindowInfo() {
170
        WindowInfo m_ViewInfo =
171
            new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
172
        m_ViewInfo.setTitle(PluginServices.getText(this, "acerca_de"));
173

  
174
        return m_ViewInfo;
175
    }
176

  
177
    public Object getWindowProfile() {
178
        return WindowInfo.DIALOG_PROFILE;
179
    }
180

  
181
    @Override
182
    public void setValue(Object value) {
183
        if (value instanceof IProjection)
184
            setCurProj((IProjection) value);
185
        else
186
            setNullValue();
187
    }
188

  
189
    public JComponent asJComponent() {
190
        return panel;
191
    }
192
    
193
    /**
194
     * This method initializes jPanel4
195
     *
196
     * @return javax.swing.JPanel
197
     */
198
    private CRSSelectPanel initJPanelProj(IProjection proj) {
199
        if (panel == null) {
200
            panel = CRSSelectPanel.getPanel(proj);
201
            panel.setTransPanelActive(true);
202
            panel.setPreferredSize(new java.awt.Dimension(330,35));
203
            panel.addActionListener(new java.awt.event.ActionListener() {
204
                public void actionPerformed(java.awt.event.ActionEvent e) {
205
                    if (panel.isOkPressed()) {
206
                        setValue(panel.getCurProj());
207
                    }
208
                }
209
            });
210
        }
211
        return panel;
212
    }
213

  
214
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/crs/JCRSDynFieldComponentFactory.java
1
package org.gvsig.app.tools.swing.serv.field.crs;
2

  
3
/* gvSIG. Geographic Information System of the Valencian Government
4
 *
5
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
6
 * of the Valencian Government (CIT)
7
 * 
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 * 
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 * 
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
21
 * MA  02110-1301, USA.
22
 * 
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 Institute of New Imaging Technologies (INIT): 
27
 *   http://www.init.uji.es
28
 * Geographic Information research group: 
29
 *   http://www.geoinfo.uji.es
30
 * Universitat Jaume I, Spain
31
 */
32

  
33
/**
34
 * 
35
 */
36

  
37
import org.gvsig.fmap.dal.DataTypes;
38
import org.gvsig.tools.service.ServiceException;
39
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
40
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponentFactory;
41
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
42
import org.gvsig.tools.swing.spi.AbstractJDynFieldComponentFactory;
43

  
44
/**
45
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
46
 * 
47
 */
48
public class JCRSDynFieldComponentFactory extends
49
    AbstractJDynFieldComponentFactory implements JDynFieldComponentFactory {
50

  
51
    /*
52
     * (non-Javadoc)
53
     * 
54
     * @see
55
     * org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryDescription
56
     * ()
57
     */
58
    @Override
59
    public String getFactoryDescription() {
60
        return null;
61
    }
62

  
63
    /*
64
     * (non-Javadoc)
65
     * 
66
     * @see
67
     * org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactorySubType()
68
     */
69
    @Override
70
    public String getFactorySubType() {
71
        return null;
72
    }
73

  
74
    /*
75
     * (non-Javadoc)
76
     * 
77
     * @see
78
     * org.gvsig.tools.swing.spi.AbstractSwingServiceFactory#getFactoryType()
79
     */
80
    @Override
81
    public Integer getFactoryType() {
82
        return DataTypes.CRS;
83
    }
84

  
85
    /*
86
     * (non-Javadoc)
87
     * 
88
     * @see
89
     * org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponentFactory
90
     * #createJDynFieldComponent(org.gvsig.tools.dynobject.DynField,
91
     * org.gvsig.tools.swing.api.dynobject.dynfield.ValueField)
92
     */
93
    public JDynFieldComponent createJDynFieldComponent(ValueField valueField,
94
        boolean writable) throws ServiceException {
95
        // TODO: take into account the writable flag
96
        return new JCRSDynFieldComponent(valueField);
97
    }
98

  
99
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/number/JNumberDynFieldComponent.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.tools.swing.serv.field.number;
23

  
24
import javax.swing.ImageIcon;
25

  
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.tools.service.ServiceException;
28
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
29

  
30

  
31
/**
32
 * @author gvSIG Team
33
 * @version $Id$
34
 *
35
 */
36
public class JNumberDynFieldComponent extends org.gvsig.tools.swing.serv.field.component.JNumberDynFieldComponent{
37

  
38
    /**
39
     * @param parent
40
     * @throws ServiceException
41
     */
42
    public JNumberDynFieldComponent(ValueField parent) throws ServiceException {
43
        super(parent);
44
    }
45
    
46
    @Override
47
    protected ImageIcon getBtnEmptyImageIcon(){
48
       return PluginServices.getIconTheme().get("editdelete-icon");
49
    }
50
   
51

  
52
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/number/JNumberDynFieldComponentFactory.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.tools.swing.serv.field.number;
23

  
24
import org.gvsig.tools.service.ServiceException;
25
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
26
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
27

  
28

  
29
/**
30
 * @author gvSIG Team
31
 * @version $Id$
32
 *
33
 */
34
public class JNumberDynFieldComponentFactory extends org.gvsig.tools.swing.serv.field.JNumberDynFieldComponentFactory{
35

  
36
    /**
37
     * @param dataType
38
     */
39
    public JNumberDynFieldComponentFactory(Integer dataType) {
40
        super(dataType);
41
    }
42

  
43

  
44
    @Override
45
    public JDynFieldComponent createJDynFieldComponent(ValueField parent,
46
        boolean writable) throws ServiceException {
47
        // TODO: take into account the writable flag
48
        return new JNumberDynFieldComponent(parent);
49
    }
50

  
51
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/date/DateDynFieldPanel.java
1
package org.gvsig.app.tools.swing.serv.field.date;
2

  
3
import java.util.Date;
4
import java.util.Locale;
5

  
6
import org.gvsig.andami.PluginServices;
7
import org.gvsig.andami.ui.mdiManager.IWindow;
8
import org.gvsig.andami.ui.mdiManager.WindowInfo;
9
import org.gvsig.tools.swing.serv.field.component.date.DateCalendarPicker;
10

  
11

  
12
public class DateDynFieldPanel extends DateCalendarPicker implements IWindow{
13

  
14
    public DateDynFieldPanel(Date date) {
15
        super(date);
16
    }
17

  
18
    public DateDynFieldPanel(Date date, Locale loc) {
19
        super(date, loc);
20
    }
21

  
22
    public WindowInfo getWindowInfo() {
23
        WindowInfo m_ViewInfo =
24
            new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
25
        m_ViewInfo.setTitle(PluginServices.getText(this, "select_date"));
26
        m_ViewInfo.setMinimumSize(new java.awt.Dimension(450, 410));
27
        return m_ViewInfo;
28
    }
29

  
30
    public Object getWindowProfile() {
31
        return WindowInfo.DIALOG_PROFILE;
32
    }
33

  
34

  
35
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/date/JDateDynFieldComponentFactory.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
/*
23
 * AUTHORS (In addition to CIT):
24
 * 2010 Institute of New Imaging Technologies (INIT): 
25
 *   http://www.init.uji.es
26
 * Geographic Information research group: 
27
 *   http://www.geoinfo.uji.es
28
 * Universitat Jaume I, Spain
29
 */
30

  
31
/**
32
 * 
33
 */
34
package org.gvsig.app.tools.swing.serv.field.date;
35

  
36
import org.gvsig.tools.service.ServiceException;
37
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponent;
38
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynFieldComponentFactory;
39
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
40

  
41
/**
42
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
43
 * 
44
 */
45
public class JDateDynFieldComponentFactory extends org.gvsig.tools.swing.serv.field.component.date.JDateDynFieldComponentFactory implements JDynFieldComponentFactory {
46

  
47
    /**
48
     * 
49
     */
50
    public JDateDynFieldComponentFactory() {
51
       super();
52
    }
53

  
54
    /**
55
     * @param type
56
     */
57
    public JDateDynFieldComponentFactory(int type) {
58
        super(type);
59
    }
60
    
61
    /**
62
     * @param type
63
     * @param subType
64
     */
65
    public JDateDynFieldComponentFactory(int type, String subType) {
66
        super(type, subType);
67
    }
68
    
69

  
70
    public JDynFieldComponent createJDynFieldComponent(ValueField parent,
71
        boolean writable) throws ServiceException {
72
        if (writable) {
73
            return new JDateDynFieldComponent(parent);
74
        } else {
75
            // TODO: Create a readonly component
76
            return new JDateDynFieldComponent(parent);
77
        }
78
    }
79
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/tools/swing/serv/field/date/JDateDynFieldComponent.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
/*
23
 * AUTHORS (In addition to CIT):
24
 * 2010 Institute of New Imaging Technologies (INIT): 
25
 *   http://www.init.uji.es
26
 * Geographic Information research group: 
27
 *   http://www.geoinfo.uji.es
28
 * Universitat Jaume I, Spain
29
 */
30

  
31
/**
32
 * 
33
 */
34
package org.gvsig.app.tools.swing.serv.field.date;
35

  
36
import java.util.Date;
37
import java.util.Locale;
38

  
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.tools.service.ServiceException;
41
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
42
import org.gvsig.tools.swing.serv.field.component.date.DateCalendarPicker;
43
import org.gvsig.tools.swing.serv.field.component.date.JDateCalendarDynFieldComponent;
44

  
45
/**
46
 * @author <a href="mailto:reinhold@uji.es">cmartin</a>
47
 * 
48
 */
49
public class JDateDynFieldComponent extends JDateCalendarDynFieldComponent {
50

  
51
    private Object window;
52
    private DateDynFieldPanel panel;
53

  
54
    public JDateDynFieldComponent(ValueField value)
55
        throws ServiceException {
56
        super(value);
57
    }
58

  
59
    @Override
60
    protected void close() {
61
        PluginServices.getMDIManager().closeWindow(panel);
62
    }
63

  
64
    @Override
65
    protected DateCalendarPicker createCalendarPicker(Date date, Locale loc) {
66
        DateDynFieldPanel datePicker = new DateDynFieldPanel(date, loc);
67
        datePicker.setPreferredSize(datePicker.getWindowInfo().getMinimumSize());
68
        return datePicker;
69
    }
70

  
71
    @Override
72
    protected void showDialog(DateCalendarPicker datePicker) {
73
        panel = (DateDynFieldPanel) datePicker;
74
        window = PluginServices.getMDIManager().addWindow(panel);
75
        if (panel.isOkPressed()){
76
            setValue(datePicker.getSelectedDate());
77
        }
78
        close();
79
        
80
    }
81
    
82
}
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/gui/command/CommandStackDialog.java
1
package org.gvsig.app.gui.command;
2

  
3
import java.awt.*;
4

  
5
import javax.swing.*;
6
import javax.swing.table.DefaultTableCellRenderer;
7
import javax.swing.table.TableColumn;
8

  
9
import org.gvsig.andami.PluginServices;
10
import org.gvsig.andami.ui.mdiManager.IWindowListener;
11
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
12
import org.gvsig.andami.ui.mdiManager.WindowInfo;
13
import org.gvsig.fmap.dal.DataStoreNotification;
14
import org.gvsig.gui.beans.DefaultBean;
15
import org.gvsig.tools.observer.Observable;
16
import org.gvsig.tools.observer.Observer;
17
import org.gvsig.tools.undo.UndoRedoInfo;
18
import org.gvsig.tools.undo.UndoRedoStack;
19

  
20

  
21
public class CommandStackDialog extends DefaultBean implements SingletonWindow, IWindowListener,Observer{
22

  
23
	private JTable jTable = null;
24
	private JPanel jPanel = null;
25
	private UndoRedoStack undoRedoStack;
26
	private JSlider jSlider = null;
27
	//private int itemCount;
28
	private int lowLimit;
29
	private int currentValue=-1;
30
	private JPanel jPanel1 = null;
31
	protected boolean refreshing;
32
	private JPanel pCenter = null;
33
	private JScrollPane jScrollPane = null;
34
	private static final ImageIcon imodify=PluginServices.getIconTheme()
35
		.get("edition-modify-command");
36
	private static final ImageIcon iadd= PluginServices.getIconTheme()
37
		.get("edition-add-command");
38

  
39
	private static final ImageIcon idel = PluginServices.getIconTheme()
40
		.get("edition-del-command");
41

  
42
	private MyModel mymodel = null;
43
	/**
44
	 * This is the default constructor
45
	 */
46
	public CommandStackDialog() {
47
		super();
48
		initialize();
49
	}
50
	public void setModel(UndoRedoStack cr1){
51
        if (this.undoRedoStack != null) {
52
            if (this.undoRedoStack.equals(cr1)) {
53
                return;
54
            } else {
55
                this.undoRedoStack.deleteObserver(this);
56
            }
57
		}
58
		this.undoRedoStack=cr1;
59
		this.undoRedoStack.addObserver(this);
60
		initTable();
61
		initSlider();
62
		currentValue=mymodel.getPos();
63
    	refreshControls();
64
		refreshScroll();
65
	}
66
	/**
67
	 * This method initializes this
68
	 *
69
	 * @return void
70
	 */
71
	private void initialize() {
72
		this.setLayout(new BorderLayout());
73
		this.setSize(328, 229);
74
		this.add(getJPanel(), java.awt.BorderLayout.NORTH);
75
		this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
76
	}
77

  
78
	/**
79
	 * This method initializes jList
80
	 *
81
	 * @return javax.swing.JList
82
	 */
83
	private JTable getTable() {
84
		if (jTable == null) {
85
			jTable = new JTable();
86
		}
87
		return jTable;
88
	}
89
	private void initTable(){
90
		mymodel=new MyModel(undoRedoStack);
91
		jTable.setModel(mymodel);
92
		jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
93
		jTable.setSelectionBackground(Color.orange);
94
		jTable.setSelectionForeground(Color.black);
95
		jTable.setShowGrid(false);
96
		jTable.getTableHeader().setBackground(Color.white);
97
		TableColumn tc = jTable.getColumnModel().getColumn(0);
98
		tc.setCellRenderer(new DefaultTableCellRenderer() {
99
			   public Component getTableCellRendererComponent(JTable table,
100
			                                               Object value,
101
			                                               boolean isSelected,
102
			                                               boolean hasFocus,
103
			                                               int row,
104
			                                               int column)
105
			      {
106
			         JLabel label = (JLabel)
107
			            super.getTableCellRendererComponent
108
			               (table, value, isSelected, hasFocus, row, column);
109
			            UndoRedoInfo info = (UndoRedoInfo) value;
110
			            switch (info.getType()) {
111
                            case UndoRedoInfo.INSERT:
112
                                label.setIcon(iadd);
113
                                break;
114
                            case UndoRedoInfo.DELETE:
115
                                label.setIcon(idel);
116
                                break;
117
                            default:
118
                                label.setIcon(imodify);
119
                        }
120
			         if (mymodel.getPos()<row){
121
			        	 label.setBackground(Color.lightGray);
122
			         }else {
123
			       		 label.setBackground(Color.orange);
124
			         }
125
			            return label;
126
			      }
127
			});
128

  
129
		jTable.addMouseListener(new java.awt.event.MouseAdapter() {
130
			public void mousePressed(java.awt.event.MouseEvent e) {
131
				int newpos=jTable.getSelectedRow();
132
				mymodel.setPos(newpos);
133
				PluginServices.getMainFrame().enableControls();
134
			}
135
		});
136
	}
137
	/**
138
	 * This method initializes jPanel
139
	 *
140
	 * @return javax.swing.JPanel
141
	 */
142
	private JPanel getJPanel() {
143
		if (jPanel == null) {
144
			jPanel = new JPanel();
145
		}
146
		return jPanel;
147
	}
148

  
149
	public WindowInfo getWindowInfo() {
150
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.ICONIFIABLE |
151
				WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.PALETTE);
152
		m_viewinfo.setTitle(PluginServices.getText(this,
153
				"pila_de_comandos"));
154
		return m_viewinfo;
155
	}
156

  
157
	public Object getWindowModel() {
158
		return mymodel.getClass().getName();
159
	}
160

  
161
	public void windowActivated() {
162
		this.validateTree();
163
	}
164

  
165
	public void windowClosed() {
166
		// TODO Auto-generated method stub
167

  
168
	}
169

  
170
	/* (non-Javadoc)
171
	 * @see com.iver.cit.gvsig.fmap.edition.commands.CommandListener#executeCommand(com.iver.cit.gvsig.fmap.edition.commands.CommandEvent)
172
	 */
173
	public void commandRepaint() {
174
		setValue(mymodel.getPos()+1,true);
175
		refreshControls();
176
		refreshScroll();
177
	}
178
	private void refreshScroll(){
179
		Dimension size=new Dimension(jSlider.getPreferredSize().width,((mymodel.getRowCount())*getTable().getRowHeight()));
180
		JScrollBar verticalScrollBar=getJScrollPane().getVerticalScrollBar();//ove(size.width,size.height);
181
		verticalScrollBar.setValue(mymodel.getPos()*getTable().getRowHeight());
182
		jSlider.setPreferredSize(size);
183
		jSlider.setSize(size);
184
		validateTree();
185
	}
186
	/**
187
	 * This method initializes jSlider
188
	 *
189
	 * @return javax.swing.JSlider
190
	 */
191
	private JSlider getJSlider() {
192
		if (jSlider == null) {
193
			jSlider = new JSlider();
194
		}
195
		return jSlider;
196
	}
197
	private void initSlider(){
198
		jSlider.setOrientation(SwingConstants.VERTICAL);
199
		jSlider.setPreferredSize(new Dimension(jSlider.getPreferredSize().width,((getTable().getRowCount())*getTable().getRowHeight())));
200
		jSlider.addMouseListener(new java.awt.event.MouseAdapter() {
201
                public void mouseReleased(java.awt.event.MouseEvent e) {
202

  
203
            	}
204
            });
205
    	jSlider.addChangeListener(new javax.swing.event.ChangeListener() {
206

  
207

  
208
				public void stateChanged(javax.swing.event.ChangeEvent e) {
209
					int value = (int) (getJSlider().getValue() * mymodel.getRowCount() * 0.01);
210
                   	if (!refreshing) {
211
						mymodel.setPos(mymodel.getRowCount()-1-value);
212
						//System.out.println("setPos = "+(cr.getCommandCount()-1-value));
213
					}
214
			    }
215
    		});
216
    	setValue(mymodel.getRowCount()-1-mymodel.getPos(),true);
217
	}
218
    public void setValue(int number, boolean fireEvent) {
219
        int rowCount=mymodel.getRowCount();
220
        if (number < lowLimit) {
221
			number = lowLimit;
222
		}
223
        if (number > rowCount) {
224
			number = rowCount;
225
		}
226
        if (number != currentValue) {
227
        	currentValue = number;
228
        	refreshControls();
229
        	if (fireEvent) {
230
				callValueChanged(new Integer(currentValue));
231
			}
232
        }
233
        int selpos=rowCount-1-number;
234
        if (selpos>=0){
235
       	 	getTable().setRowSelectionInterval(selpos,selpos);
236
        } else {
237
			getTable().clearSelection();
238
		}
239
    }
240
    /**
241
     * Refreshes all the mutable controls in this component.
242
     */
243
    private void refreshControls() {
244
    	int normalizedValue = (int) (((mymodel.getRowCount()-currentValue) / (float) mymodel.getRowCount())*100);
245
		refreshSlider(normalizedValue);
246
		jTable.repaint();
247
	}
248
    /**
249
	 * Sets the slider to the correct (scaled) position.
250
     * @param normalizedValue
251
     */
252
    private void refreshSlider(int normalizedValue) {
253
    	refreshing = true;
254
        getJSlider().setValue(normalizedValue);
255
        refreshing = false;
256
    }
257

  
258
	/**
259
	 * This method initializes jPanel1
260
	 *
261
	 * @return javax.swing.JPanel
262
	 */
263
	private JPanel getJPanel1() {
264
		if (jPanel1 == null) {
265
			jPanel1 = new JPanel();
266
			jPanel1.add(getJSlider());
267
		}
268
		return jPanel1;
269
	}
270

  
271

  
272

  
273
	/**
274
	 * This method initializes pCenter
275
	 *
276
	 * @return javax.swing.JPanel
277
	 */
278
	private JPanel getPCenter() {
279
		if (pCenter == null) {
280
			pCenter = new JPanel();
281
			pCenter.setLayout(new BorderLayout());
282
			pCenter.add(getTable(), java.awt.BorderLayout.CENTER);
283
			pCenter.add(getJPanel1(), java.awt.BorderLayout.WEST);
284
		}
285
		return pCenter;
286
	}
287

  
288
	/**
289
	 * This method initializes jScrollPane
290
	 *
291
	 * @return javax.swing.JScrollPane
292
	 */
293
	private JScrollPane getJScrollPane() {
294
		if (jScrollPane == null) {
295
			jScrollPane = new JScrollPane();
296
			jScrollPane.setViewportView(getPCenter());
297
		}
298
		return jScrollPane;
299
	}
300
	public void update(Observable observable, Object notification) {
301
//	    if (notification instanceof DataStoreNotification) {
302
//            DataStoreNotification storeNotification = (DataStoreNotification) notification;
303
//            if (DataStoreNotification.SELECTION_CHANGE.equals(storeNotification
304
//                    .getType())) {
305
//                commandRepaint();
306
//            }
307
//        }
308
	    commandRepaint();
309
	}
310

  
311
	public Object getWindowProfile() {
312
		return WindowInfo.DIALOG_PROFILE;
313
	}
314

  
315
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 316

  
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/gui/command/ColorRenderer.java
1
package org.gvsig.app.gui.command;
2
import java.awt.Color;
3
import java.awt.Component;
4

  
5
import javax.swing.BorderFactory;
6
import javax.swing.JLabel;
7
import javax.swing.JTable;
8
import javax.swing.border.Border;
9
import javax.swing.table.TableCellRenderer;
10

  
11
public class ColorRenderer extends JLabel
12
                           implements TableCellRenderer {
13
    Border unselectedBorder = null;
14
    Border selectedBorder = null;
15
    boolean isBordered = true;
16

  
17
    public ColorRenderer(boolean isBordered) {
18
        this.isBordered = isBordered;
19
        setOpaque(true); //MUST do this for background to show up.
20
    }
21

  
22
    public Component getTableCellRendererComponent(
23
                            JTable table, Object color,
24
                            boolean isSelected, boolean hasFocus,
25
                            int row, int column) {
26
        Color newColor = (Color)color;
27
        setBackground(newColor);
28
        if (isBordered) {
29
            if (isSelected) {
30
                if (selectedBorder == null) {
31
                    selectedBorder = BorderFactory.createMatteBorder(2,5,2,5,
32
                                              table.getSelectionBackground());
33
                }
34
                setBorder(selectedBorder);
35
            } else {
36
                if (unselectedBorder == null) {
37
                    unselectedBorder = BorderFactory.createMatteBorder(2,5,2,5,
38
                                              table.getBackground());
39
                }
40
                setBorder(unselectedBorder);
41
            }
42
        }
43

  
44
        setToolTipText("RGB value: " + newColor.getRed() + ", "
45
                                     + newColor.getGreen() + ", "
46
                                     + newColor.getBlue());
47
        return this;
48
    }
49
}
0 50

  
tags/v2_0_0_Build_2025/applications/appgvSIG/appgvSIG/src/org/gvsig/app/gui/command/MyModel.java
1
package org.gvsig.app.gui.command;
2

  
3
import javax.swing.table.AbstractTableModel;
4

  
5
import org.gvsig.tools.undo.RedoException;
6
import org.gvsig.tools.undo.UndoException;
7
import org.gvsig.tools.undo.UndoRedoStack;
8
import org.gvsig.tools.undo.command.Command;
9

  
10

  
11
public class MyModel extends AbstractTableModel{
12
private UndoRedoStack cr;
13
public MyModel(UndoRedoStack cr) {
14
	this.cr=cr;
15
	}
16
	public int getPos() {
17
		return cr.getUndoInfos().size()-1;
18
	}
19
	public int getColumnCount() {
20
		return 1;
21
	}
22
	public int getRowCount() {
23
		return cr.getRedoInfos().size()+cr.getUndoInfos().size();
24
	}
25
	public Object getValueAt(int i, int j) {
26
		Command[] undos=(Command[])cr.getUndoInfos().toArray(new Command[0]);
27
		Command[] redos=(Command[])cr.getRedoInfos().toArray(new Command[0]);
28
		if (i<undos.length){
29
			//System.out.println("undo i=" + i + " index=" + (undos.length-1-i));
30
			return undos[undos.length-1-i];
31
		}else{
32
			//System.out.println("redo i=" + i + " index=" + (i-undos.length));
33
			return redos[i-undos.length];
34
		}
35
	}
36
	public void setPos(int newpos) {
37
		try {
38
			if (newpos>getPos()){
39
				cr.redo(newpos-getPos());
40

  
41
			}else{
42
				cr.undo(getPos()-newpos);
43
			}
44
		} catch (RedoException e) {
45
			e.printStackTrace();
46
		} catch (UndoException e) {
47
			e.printStackTrace();
48
		}
49
	}
50
}
0 51

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff