コード例 #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
  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);
  }