Revision 43198
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/actions/EliminarCapaTocMenuEntry.java | ||
---|---|---|
25 | 25 |
import java.awt.Component; |
26 | 26 |
|
27 | 27 |
import javax.swing.JOptionPane; |
28 |
import org.apache.commons.lang3.StringUtils; |
|
28 | 29 |
|
29 | 30 |
import org.gvsig.andami.PluginServices; |
30 | 31 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
32 |
import org.gvsig.app.ApplicationLocator; |
|
33 |
import org.gvsig.app.ApplicationManager; |
|
31 | 34 |
import org.gvsig.app.extension.ProjectExtension; |
32 | 35 |
import org.gvsig.app.project.Project; |
33 | 36 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
34 | 37 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
35 | 38 |
import org.gvsig.fmap.mapcontext.layers.CancelationException; |
36 | 39 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
40 |
import org.gvsig.tools.ToolsLocator; |
|
41 |
import org.gvsig.tools.i18n.I18nManager; |
|
37 | 42 |
|
38 | 43 |
public class EliminarCapaTocMenuEntry extends AbstractTocContextMenuAction { |
39 | 44 |
|
... | ... | |
66 | 71 |
} |
67 | 72 |
|
68 | 73 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
69 |
|
|
74 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
75 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
70 | 76 |
FLayer[] actives = selectedItems; |
71 |
|
|
77 |
if( actives == null ) { |
|
78 |
return; |
|
79 |
} |
|
72 | 80 |
int i; |
73 | 81 |
for (i = 0; i < actives.length; i++) { |
74 | 82 |
if (actives[i].isEditing() && actives[i].isAvailable()) { |
... | ... | |
76 | 84 |
return; |
77 | 85 |
} |
78 | 86 |
} |
79 |
|
|
80 |
int option = -1; |
|
81 |
if (actives.length > 0) { |
|
82 |
option = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(), PluginServices.getText(this, "desea_borrar_la_capa")); |
|
83 |
} else { |
|
87 |
if (actives.length <= 0) { |
|
84 | 88 |
return; |
85 | 89 |
} |
86 |
if (option != JOptionPane.OK_OPTION) { |
|
90 |
int option = application.confirmDialog( |
|
91 |
i18n.getTranslation("desea_borrar_la_capa"), |
|
92 |
i18n.getTranslation("_Question"), |
|
93 |
JOptionPane.YES_NO_OPTION, |
|
94 |
JOptionPane.QUESTION_MESSAGE, |
|
95 |
"Confirm remove layer from the view" |
|
96 |
); |
|
97 |
if (option != JOptionPane.YES_OPTION) { |
|
87 | 98 |
return; |
88 | 99 |
} |
89 | 100 |
getMapContext().beginAtomicEvent(); |
90 | 101 |
for (i = actives.length - 1; i >= 0; i--) { |
91 | 102 |
try { |
92 |
//actives[i].getParentLayer().removeLayer(actives[i]); |
|
93 |
//FLayers lyrs=getMapContext().getLayers(); |
|
94 |
//lyrs.addLayer(actives[i]); |
|
95 | 103 |
actives[i].getParentLayer().removeLayer(actives[i]); |
96 | 104 |
|
97 | 105 |
//Cierra todas las ventanas asociadas a la capa |
... | ... | |
99 | 107 |
for (int j = 0; j < wList.length; j++) { |
100 | 108 |
String name = wList[j].getWindowInfo().getAdditionalInfo(); |
101 | 109 |
for (int k = 0; k < actives.length; k++) { |
102 |
if (name != null && actives != null && actives[k] != null |
|
103 |
&& actives[k].getName() != null |
|
104 |
&& name.compareTo(actives[k].getName()) == 0) { |
|
110 |
if ( StringUtils.equals(name, actives[k].getName()) ) { |
|
105 | 111 |
PluginServices.getMDIManager().closeWindow(wList[j]); |
106 | 112 |
} |
107 | 113 |
} |
... | ... | |
124 | 130 |
Project project = ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject(); |
125 | 131 |
project.setModified(true); |
126 | 132 |
PluginServices.getMainFrame().enableControls(); |
127 |
// 050209, jmorell: As? solo borra una capa (sobre la que pulsas). |
|
128 |
/*FLayer lyr = getNodeLayer(); |
|
129 |
try { |
|
130 |
getMapContext().getLayers().removeLayer(lyr); |
|
131 |
if (getMapContext().getLayers().getLayersCount()==0)PluginServices.getMainFrame().enableControls(); |
|
132 |
} catch (CancelationException e1) { |
|
133 |
e1.printStackTrace(); |
|
134 |
}*/ |
|
135 | 133 |
} |
136 | 134 |
} |
Also available in: Unified diff