Revision 34833 branches/v2_0_0_prep/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiManager/WindowInfo.java

View differences:

WindowInfo.java
45 45
import java.beans.PropertyChangeListener;
46 46
import java.beans.PropertyChangeSupport;
47 47
import java.util.HashMap;
48
import java.util.Map;
48 49

  
49 50
import org.exolab.castor.xml.XMLException;
50 51
import org.gvsig.andami.PluginServices;
52
import org.gvsig.tools.ToolsLocator;
53
import org.gvsig.tools.dynobject.DynStruct;
54
import org.gvsig.tools.persistence.PersistenceManager;
55
import org.gvsig.tools.persistence.Persistent;
56
import org.gvsig.tools.persistence.PersistentState;
57
import org.gvsig.tools.persistence.exception.PersistenceException;
58
import org.gvsig.tools.util.Callable;
51 59
import org.gvsig.utils.XMLEntity;
52 60

  
53 61

  
......
64 72
 *
65 73
 * @author Fernando Gonz?lez Cort?s
66 74
 */
67
public class WindowInfo {
75
public class WindowInfo implements Persistent{
76
	
77
	public static final String PERSISTENCE_DEFINITION_NAME = "WindowInfo";
78

  
68 79
	/** Specifies that the window is resizable  */
69 80
    public static final int RESIZABLE = 1;
70 81

  
......
160 171
     * para activar el tool que estaba seleccionado en
161 172
     * la vista, cuando volvemos a ella.
162 173
     */
163
    private HashMap selectedTools = null;
174
    @SuppressWarnings("rawtypes")
175
	private Map selectedTools = null;
164 176
    // this should be the same value defined at plugin-config.xsd
165 177
    private String defaultGroup = "unico";
166 178

  
......
581 593
     * @return A HashMap containing pairs (group, actionCommand), which
582 594
     * are the selected tools for this window.
583 595
     */
584
    public HashMap getSelectedTools() {
596
    @SuppressWarnings("rawtypes")
597
	public Map getSelectedTools() {
585 598
        return selectedTools;
586 599
    }
587 600

  
......
591 604
     * @param selectedTool
592 605
     * @deprecated
593 606
     */
594
    public void setSelectedTool(String selectedTool) {
607
    @SuppressWarnings("unchecked")
608
	public void setSelectedTool(String selectedTool) {
595 609
        if (selectedTool != null)
596 610
            selectedTools.put(defaultGroup ,selectedTool);
597 611
    }
......
603 617
     * (group, actionCommand), which will be set as the selected tools
604 618
     * for this window.
605 619
     */
606
    public void setSelectedTools(HashMap selectedTools) {
620
    @SuppressWarnings("rawtypes")
621
	public void setSelectedTools(Map selectedTools) {
607 622
        if (selectedTools != null)
608 623
            this.selectedTools = selectedTools;
609 624
    }
......
1140 1155
		this.additionalInfo = additionalInfo;
1141 1156
	}
1142 1157

  
1158
	public void saveToState(PersistentState state) throws PersistenceException {
1159
	    state.set("resizable", this.resizable);
1160
	    state.set("maximizable", this.maximizable);
1161
	    state.set("iconifiable", this.iconifiable);
1162
	    state.set("modal", this.modal);
1163
	    state.set("modeless", this.modeless);
1164
	    state.set("notclosable", this.notclosable);
1165
	    state.set("persistWindow", this.persistWindow); //OJO ?Obsoleto?
1166
	    state.set("palette", this.palette);
1167
	    state.set("additionalInfo", this.additionalInfo);
1168
	    state.set("width", this.width);
1169
	    state.set("height", this.height);
1170
	    state.set("x", this.x);
1171
	    state.set("y", this.y);
1172
	    state.set("normalX", this.normalX);
1173
	    state.set("normalY", this.normalY);
1174
	    state.set("normalHeight", this.normalHeight);
1175
	    state.set("normalWidth", this.normalWidth);
1176
	    state.set("minSize", this.minSize);
1177
	    state.set("isMaximized", this.isMaximized);
1178
	    state.set("visible", this.visible);
1179
	    state.set("isClosed", this.isClosed);
1180
	    state.set("title", this.title);
1181
	    state.set("id", this.id); //OJO
1182
	    state.set("selectedTools", this.selectedTools); //OJO
1183
	    state.set("defaultGroup", this.defaultGroup); //OJO
1184
	}
1185

  
1186
	@SuppressWarnings("rawtypes")
1187
	public void loadFromState(PersistentState state)
1188
			throws PersistenceException {
1189
	    this.resizable = state.getBoolean("resizable");
1190
	    this.maximizable = state.getBoolean("maximizable");
1191
	    this.iconifiable = state.getBoolean("iconifiable");
1192
	    this.modal = state.getBoolean("modal");
1193
	    this.modeless = state.getBoolean("modeless");
1194
	    this.notclosable = state.getBoolean("notclosable");
1195
	    this.persistWindow = state.getBoolean("persistWindow"); //OJO ?Obsoleto?
1196
	    this.palette = state.getBoolean("palette");
1197
	    this.additionalInfo = state.getString("additionalInfo");
1198
	    this.width = state.getInt("width");
1199
	    this.height = state.getInt("height");
1200
	    this.x = state.getInt("x");
1201
	    this.y = state.getInt("y");
1202
	    this.normalX = state.getInt("normalX");
1203
	    this.normalY = state.getInt("normalY");
1204
	    this.normalHeight = state.getInt("normalHeight");
1205
	    this.normalWidth = state.getInt("normalWidth");
1206
	    this.minSize = (Dimension)state.get("minSize");
1207
	    this.isMaximized = state.getBoolean("isMaximized");
1208
	    this.visible = state.getBoolean("visible");
1209
	    this.isClosed = state.getBoolean("isClosed");
1210
	    this.title = state.getString("title");
1211
	    this.id = state.getInt("id");
1212
	    this.setSelectedTools(state.getMap("selectedTools"));
1213
	    this.defaultGroup = state.getString("defaultGroup"); //OJO
1214
	}
1215

  
1216
	
1217
    public static class RegisterPersistence implements Callable {
1218

  
1219
        public Object call() throws Exception {
1220
    		PersistenceManager manager = ToolsLocator.getPersistenceManager();
1221
    		DynStruct definition = manager.getDefinition(PERSISTENCE_DEFINITION_NAME);
1222
    		if ( definition == null ){
1223
    		    definition = manager.addDefinition(
1224
    		        WindowInfo.class,
1225
    		        PERSISTENCE_DEFINITION_NAME,
1226
    		        "WindowInfo persistence definition",
1227
    		        null, 
1228
    		        null
1229
    		    );
1230
    		    definition.addDynFieldBoolean("resizable").setMandatory(true);
1231
    		    definition.addDynFieldBoolean("maximizable").setMandatory(true);
1232
    		    definition.addDynFieldBoolean("iconifiable").setMandatory(true);
1233
    		    definition.addDynFieldBoolean("modal").setMandatory(true);
1234
    		    definition.addDynFieldBoolean("modeless").setMandatory(true);
1235
    		    definition.addDynFieldBoolean("notclosable").setMandatory(true);
1236
    		    definition.addDynFieldBoolean("persistWindow").setMandatory(true);
1237
    		    definition.addDynFieldBoolean("palette").setMandatory(true);
1238
    		    definition.addDynFieldString("additionalInfo").setMandatory(false);
1239
    		    definition.addDynFieldInt("width").setMandatory(true);
1240
    		    definition.addDynFieldInt("height").setMandatory(true);
1241
    		    definition.addDynFieldInt("x").setMandatory(true);
1242
    		    definition.addDynFieldInt("y").setMandatory(true);
1243
    		    definition.addDynFieldInt("normalX").setMandatory(true);
1244
    		    definition.addDynFieldInt("normalY").setMandatory(true);
1245
    		    definition.addDynFieldInt("normalHeight").setMandatory(true);
1246
    		    definition.addDynFieldInt("normalWidth").setMandatory(true);
1247
    		    definition.addDynFieldObject("minSize").setMandatory(false).setClassOfValue(Dimension.class);
1248
    		    definition.addDynFieldBoolean("isMaximized").setMandatory(true);
1249
    		    definition.addDynFieldBoolean("visible").setMandatory(true);
1250
    		    definition.addDynFieldBoolean("isClosed").setMandatory(true);
1251
    		    definition.addDynFieldString("title").setMandatory(true);
1252
    		    definition.addDynFieldInt("id").setMandatory(true);
1253
    		    definition.addDynFieldMap("selectedTools").setMandatory(false);
1254
    		    definition.addDynFieldString("defaultGroup").setMandatory(true);
1255
    		}
1256
    	    return Boolean.TRUE;
1257
        }
1258
    }
1143 1259
}

Also available in: Unified diff