Revision 37852 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/InternalPolygonExtension.java

View differences:

InternalPolygonExtension.java
68 68
	 * @see org.gvsig.andami.plugins.IExtension#initialize()
69 69
	 */
70 70
	public void initialize() {
71
		internalpolygon=new InternalPolygonCADTool();
72
       CADExtension.addCADTool("_internalpolygon",internalpolygon);
71
	    internalpolygon = new InternalPolygonCADTool();
72
	    CADExtension.addCADTool("_internalpolygon",internalpolygon);
73 73

  
74
       registerIcons();
74
	    registerIcons();
75 75
	}
76 76

  
77 77
	private void registerIcons(){
78
		PluginServices.getIconTheme().registerDefault(
79
				"edition-modify-geometry-internalpolygon",
80
				this.getClass().getClassLoader().getResource("images/InternalPolygon.png")
81
			);
82

  
78
	    PluginServices.getIconTheme().registerDefault(
79
	        "edition-modify-geometry-internalpolygon",
80
	        this.getClass().getClassLoader().getResource("images/InternalPolygon.png")
81
	    );
83 82
	}
84 83

  
85 84
	/**
86 85
	 * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
87 86
	 */
88 87
	public void execute(String s) {
89
		CADExtension.initFocus();
90
		if (s.equals("_internalpolygon")) {
91
        	CADExtension.setCADTool(s,true);
92
        }
93
		CADExtension.getEditionManager().setMapControl(mapControl);
94
		CADExtension.getCADToolAdapter().configureMenu();
88
	    CADExtension.initFocus();
89
	    if (s.equals("_internalpolygon")) {
90
	        CADExtension.setCADTool(s,true);
91
	    }
92
	    CADExtension.getEditionManager().setMapControl(mapControl);
93
	    CADExtension.getCADToolAdapter().configureMenu();
95 94
	}
96 95

  
97 96
	/**
......
100 99
	public boolean isEnabled() {
101 100

  
102 101
		try {
103
			if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
104
				view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow();
105
				mapControl = view.getMapControl();
106
				EditionManager em=CADExtension.getEditionManager();
107
				if (em.getActiveLayerEdited()==null)
108
					return false;
109
				VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
110
				if (((FeatureSelection)vle.getFeatureStore().getSelection()).getSize()<1)
111
					return false;
112
				FLyrVect lv=(FLyrVect)vle.getLayer();
113
//				ArrayList selectedRows=vle.getSelectedRow();
114
//				if (selectedRows.size()<1) {
115
//					return false;
116
//				}
117
				if (internalpolygon.isApplicable(lv.getShapeType())){
118
					return true;
119
				}
120
			}
102
		    if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
103
		        view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow();
104
		        mapControl = view.getMapControl();
105
		        EditionManager em=CADExtension.getEditionManager();
106
		        if (em.getActiveLayerEdited()==null)
107
		            return false;
108
		        VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
109
		        if (((FeatureSelection)vle.getFeatureStore().getSelection()).getSize()<1)
110
		            return false;
111
		        FLyrVect lv=(FLyrVect)vle.getLayer();
112
		        if (internalpolygon.isApplicable(lv.getShapeType())){
113
		            return true;
114
		        }
115
		    }
121 116
		} catch (ReadException e) {
122 117
			NotificationManager.addError(e.getMessage(),e);
123 118
		} catch (DataException e) {
......
130 125
	 * @see org.gvsig.andami.plugins.IExtension#isVisible()
131 126
	 */
132 127
	public boolean isVisible() {
133
		if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
134
			return true;
135
		return false;
128
	    if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
129
	        return true;
130
	    return false;
136 131
	}
137 132
}

Also available in: Unified diff