0
头像

类 DocumentNoteUtilities 示例代码

在这个类的文档中,你有一些表单的示例代码......

java.util.List noteFields = new ArrayList();
String fieldCode = "国家";
noteFields.add(DocumentNoteField.createTextNoteField("Country", "标本采集的国家", fieldCode, Collections.emptyList(), false));
String noteTypeCode = "DocumentNoteUtilities-TestNote";
DocumentNoteType noteType = DocumentNoteUtilities.getNoteType(noteTypeCode);
if (noteType == null) { //如果还没有添加笔记类型,则创建并添加它
noteType = DocumentNoteUtilities.createNewNoteType("测试笔记", noteTypeCode, "测试笔记", noteFields, true);
DocumentNoteUtilities.setNoteType(noteType);
}
DocumentNote note = noteType.createDocumentNote();
note.setFieldValue(fieldCode, "一个值!");
AnnotatedPluginDocument.DocumentNotes documentNotes = doc.getDocumentNotes(true);
documentNotes.setNote(note);
documentNotes.saveNotes();

在 Eclipse 32 位下使用 Geneious Plugin SDK 我得到错误...

方法 createTextNoteField(String, String, String, List<Constraint> , boolean) 类型的 DocumentNoteField 不适用于参数 (String, String, String, List<Object> , 布尔值)

有任何想法吗?这可能是微不足道的 - 我不是 Java 开发人员

杰瑞·库珀

5 条评论

0
头像

你好呀。  听起来此文档不正确,但我无法对其进行跟踪。这个文档在哪里?  这是插件开发工具包的最新版本(6.0.5)吗?

艾米威尔逊 0 票
评论动作 永久链接
0
头像

我使用插件 SDK 6.05 或 6.03 得到相同的结果。

示例代码在...

/geneious-devkit/geneious-6.0.5-devkit/api-javadoc/com/biomatters/geneious/publicapi/documents/DocumentNoteUtilities.html

杰瑞·库珀 0 票
评论动作 永久链接
0
头像

有些代码看起来与您在 DocumentNoteUtilities.html 中的代码相似,但前 3 行不同。  他们读:

java.util.List noteFields = new ArrayList(); String fieldCode = "Field1"; noteFields.add(DocumentNoteField.createTextNoteField("Field no.1", "第一个字段", fieldCode, Collections.emptyList(), false));

前 3 行是否改编自您自己编写的代码?  如果是这样,您可以通过添加<Constraint>回到第 2 行。

艾米威尔逊 0 票
评论动作 永久链接
0
头像

好的。如果我让演员阵容...

String fieldCode = "Field1"; noteFields.add(DocumentNoteField.createTextNoteField("Field no.1", "第一个字段", fieldCode, (List) Collections.emptyList(), false));

        

杰瑞·库珀 0 票
评论动作 永久链接
0
头像

该方法采用约束列表。  当它只是说 Collections.emptyList() 时,它正在创建一个对象列表。  与收藏。<Constraint> emptyList() 与示例中一样,它创建了一个约束列表。  使用 (List)Collections.emptyList(),它会创建一个未知类型的列表。

虽然在这种情况下使用 (List)Collections.emptyList() 不会引起问题,但我建议您养成使用表单集合的习惯。<Constraint> emptyList() 因为在其他类似情况下这将避免错误。

艾米威尔逊 0 票
评论动作 永久链接