0
我有一个MultiViewEditorElement
的子类。我知道该类正在实例化,但由于某种原因,打开文件时,componentOpened和componentActivated未被触发。我在这里做错了什么?我只包括了我认为相关的代码,请让我知道你是否需要整个班级。componentOpened未在MultiViewEditorElement的子类上触发
类声明
@MultiViewElement.Registration(
displayName = "#LBL_puml_EDITOR",
iconBase = "org/netbeans/modules/plantumlnb/icon.png",
mimeType = "text/plain",
persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
preferredID = "puml",
position = 1000)
@Messages("LBL_puml_EDITOR=Source")
public final class pumlVisualElement extends MultiViewEditorElement {
public pumlVisualElement(Lookup lkp) {
super(lkp);
obj = lkp.lookup(pumlDataObject.class);
System.out.println("================ Inside Constructor.");
assert obj != null;
}
@Override
public void componentOpened() {
super.componentOpened();
System.out.println(" ========================= Here");
}
@Override
public void componentActivated() {
super.componentActivated();
System.out.println(" ========================= Here");
}
}
方法实例化上面的类
@MultiViewElement.Registration(
displayName = "#LBL_puml_EDITOR",
iconBase = "org/netbeans/modules/plantumlnb/icon.png",
mimeType = "text/x-puml",
persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
preferredID = "puml",
position = 1200)
@Messages("LBL_puml_EDITOR=Source")
public static MultiViewEditorElement createEditor(Lookup lkp) {
return ((MultiViewEditorElement) new pumlVisualElement(lkp));
}