Revision 26053 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/TableEditInsertExtension.java

View differences:

TableEditInsertExtension.java
40 40
 */
41 41
package com.iver.cit.gvsig;
42 42

  
43
import org.gvsig.fmap.dal.exception.ReadException;
44
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
43
import org.gvsig.fmap.dal.exception.DataException;
45 44

  
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.messages.NotificationManager;
48
import com.iver.andami.plugins.Extension;
49
import com.iver.andami.ui.mdiManager.IWindow;
50 45

  
51

  
52 46
/**
53 47
 * DOCUMENT ME!
54 48
 *
55 49
 * @author Vicente Caballero Navarro
56 50
 */
57
public class TableEditInsertExtension extends Extension {
58
    /**
59
     * @see com.iver.andami.plugins.IExtension#initialize()
60
     */
61
    public void initialize() {
62
    }
51
public class TableEditInsertExtension extends AbstractTableEditExtension {
63 52

  
64 53
    /**
65 54
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
66 55
     */
67 56
    public void execute(String actionCommand) {
68 57
        if ("INSERTROW".equals(actionCommand)) {
69
            IWindow v = PluginServices.getMDIManager().getActiveWindow();
70

  
71
//            FIXME
72
//            try {
73
//                ((FeatureTableDocumentPanel) v).addFeatures(null);
74
//            } catch (ReadException e) {
75
//				 NotificationManager.addError("No se pudo insertar la fila", e);
76
//			}
58
           try {
59
        	   	featureTableOperations.setStore(table.getModel().getStore());
60
           		featureTableOperations.insertNewFeature();
61
			} catch (DataException e) {
62
				e.printStackTrace();
63
			}
77 64
        }
78 65

  
79 66
    }
......
82 69
     * @see com.iver.andami.plugins.IExtension#isEnabled()
83 70
     */
84 71
    public boolean isEnabled() {
85
    	return true;
72
    	return (table.getModel().getAssociatedLayer()==null);
86 73
    }
87 74

  
88
    /**
89
     * @see com.iver.andami.plugins.IExtension#isVisible()
90
     */
91
    public boolean isVisible() {
92
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
93

  
94
        if (v == null) {
95
            return false;
96
        } else if (v instanceof FeatureTableDocumentPanel && ((FeatureTableDocumentPanel) v).getModel().getStore().isEditing()) {
97
            return true;
98
        } else {
99
            return false;
100
        }
101
    }
102
}
75
  }

Also available in: Unified diff