public void execute(ITocItem item, FLayer[] selectedItems) {
   FLayer lyr = getNodeLayer(item);
   if (!lyr.isAvailable()) return;
   ChangeName chn = new ChangeName(lyr.getName());
   PluginServices.getMDIManager().addWindow(chn);
   lyr.setName(chn.getName());
   Project project =
       ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject();
   project.setModified(true);
 }
  public boolean isEnabled(ProjectDocument item, ProjectDocument[] selectedItems) {
    String sourceString = PluginServices.getFromClipboard();
    if (sourceString == null) return false;

    ProjectExtension projectExtension =
        (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
    Project project = projectExtension.getProject();
    String docType = ((ProjectWindow) projectExtension.getProjectWindow()).getDocumentSelected();

    return project.isValidXMLForImport(sourceString, docType);
  }
  /**
   * Returns true if there is a layer in the current project using the file named with fileName.
   *
   * @param fileName
   * @return
   */
  private boolean isUsingFile(String fileName) {
    ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
    ArrayList<ProjectDocument> docs = ext.getProject().getDocuments();

    for (int i = 0; i < docs.size(); i++) {
      if (docs.get(i) instanceof ProjectViewBase) {
        FLayers lyrs = ((ProjectViewBase) docs.get(i)).getMapContext().getLayers();
        for (int j = 0; j < lyrs.getLayersCount(); j++) {
          if (lyrs.getLayer(j) instanceof FLyrRasterSE) {
            FLyrRasterSE lyr = (FLyrRasterSE) lyrs.getLayer(j);
            if (lyr.getDataSource() != null)
              if (lyr.getDataSource().getDataset(0)[0] != null)
                if (lyr.getDataSource().getDataset(0)[0].getFName().equals(fileName)) return true;
          }
        }
      }
    }
    return false;
  }
  public void execute(ProjectDocument item, ProjectDocument[] selectedItems) {
    String sourceString = PluginServices.getFromClipboard();
    if (sourceString == null) return;

    ProjectExtension projectExtension =
        (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
    Project project = projectExtension.getProject();
    String docType = ((ProjectWindow) projectExtension.getProjectWindow()).getDocumentSelected();

    try {
      project.importFromXML(sourceString, docType);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          (Component) PluginServices.getMainFrame(),
          "<html>"
              + PluginServices.getText(this, "No_ha_sido_posible_realizar_la_operacion")
              + "</html>", // Mensaje
          PluginServices.getText(this, "pegar"), // titulo
          JOptionPane.ERROR_MESSAGE);
    }
    project.setModified(true);
  }
  public void execute(ITocItem item, FLayer[] selectedItems) {
    // ITocItem tocItem = (ITocItem) getNodeUserObject();
    ChangeName changename = new ChangeName(null);
    PluginServices.getMDIManager().addWindow(changename);
    if (!changename.isAccepted()) return;
    String nombre = changename.getName();

    if (nombre != null) {

      getMapContext().beginAtomicEvent();
      FLayers parent = selectedItems[0].getParentLayer();
      //			FLayers newGroup = new FLayers(getMapContext(),parent);
      FLayers newGroup = getMapContext().getNewGroupLayer(parent);
      newGroup.setName(nombre);
      int pos = 0;
      for (int i = 0; i < parent.getLayersCount(); i++) {
        if (parent.getLayer(i).equals(selectedItems[0])) {
          pos = i;
          continue;
        }
      }
      for (int j = 0; j < selectedItems.length; j++) {
        FLayer layer = selectedItems[j];
        parent.removeLayer(layer);
        newGroup.addLayer(layer);
      }
      parent.addLayer(pos, newGroup);

      getMapContext().endAtomicEvent();
      // TRUCO PARA REFRESCAR.
      getMapContext().invalidate();
      Project project =
          ((ProjectExtension) PluginServices.getExtension(ProjectExtension.class)).getProject();
      project.setModified(true);
    }
  }