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); }
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); }