コード例 #1
0
  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);
  }
コード例 #2
0
  /**
   * 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;
  }
コード例 #3
0
  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);
  }