gpt4 book ai didi

java - 如何在Eclipse中的Expressions View 中正确实现自定义详细信息 Pane ?

转载 作者:太空宇宙 更新时间:2023-11-04 07:10:56 25 4
gpt4 key购买 nike

我为 org.eclipse.debug.ui.detailPaneFactories 做出了贡献,它替换了 Eclipse 调试器中 Variables View 内的详细信息 Pane :

enter image description here

上面的详细信息 Pane 被重新定义为黄色。

不幸的是,Expressions View 中的详细信息 Pane 不起作用,下面是灰色的:

enter image description here

我做错了什么?

我尝试实现以下示例:http://alvinalexander.com/java/jwarehouse/eclipse/org.eclipse.jdt.debug.tests/test-plugin/org/eclipse/jdt/debug/testplugin/detailpane/SimpleDetailPane.java.shtml

我的plugin.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>

<plugin>
<extension
point="org.eclipse.debug.ui.detailPaneFactories">
<detailFactories
class="tests.debug.details.DetailPaneFactory"
id="tests.debug.details.detailFactories">
</detailFactories>
</extension>



</plugin>

我的DetailPaneFactory.java如下:

package tests.debug.details;

import java.util.AbstractSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.eclipse.debug.ui.IDetailPane;
import org.eclipse.debug.ui.IDetailPaneFactory;
import org.eclipse.jface.viewers.IStructuredSelection;

public class DetailPaneFactory implements IDetailPaneFactory {

private HashMap<String,Class<? extends IDetailPane>> classes = new HashMap<String,Class<? extends IDetailPane>>();

private void addClass(Class<? extends IDetailPane> cls) {
try {
String paneID = (String) cls.getField("ID").get(null);
classes.put(paneID, cls);
} catch (IllegalArgumentException | IllegalAccessException
| NoSuchFieldException | SecurityException e) {
throw new RuntimeException(e);
}
finally {

}

}

private Class<? extends IDetailPane> getClass(String paneID) {
Class<? extends IDetailPane> ans = classes.get(paneID);
return ans;
}

public DetailPaneFactory() {
addClass(SimpleDetailPane.class);
}


@Override
public IDetailPane createDetailPane(String paneID) {

Class<? extends IDetailPane> cls = getClass(paneID);
if( cls != null ) {
try {
return cls.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException();
}
}
else {
return null;
}
}

@Override
public String getDetailPaneName(String paneID) {
Class<? extends IDetailPane> cls = getClass(paneID);
if( cls != null ) {
try {
return (String)cls.getField("NAME").get(null);
} catch (IllegalArgumentException | IllegalAccessException
| NoSuchFieldException | SecurityException e) {
throw new RuntimeException(e);
}
}
else {
return null;
}
}

@Override
public String getDetailPaneDescription(String paneID) {
Class<? extends IDetailPane> cls = getClass(paneID);
if( cls != null ) {
try {
return (String)cls.getField("DESCRIPTION").get(null);
} catch (IllegalArgumentException | IllegalAccessException
| NoSuchFieldException | SecurityException e) {
throw new RuntimeException(e);
}
}
else {
return null;
}
}

@Override
public Set<String> getDetailPaneTypes(IStructuredSelection selection) {
return new AbstractSet<String>() {

@Override
public Iterator<String> iterator() {
return new Iterator<String>() {

private Iterator<Map.Entry<String,Class<? extends IDetailPane>>> it = classes.entrySet().iterator();

@Override
public void remove() {
it.remove();
}

@Override
public String next() {
return it.next().getKey();
}

@Override
public boolean hasNext() {
return it.hasNext();
}
};
}

@Override
public int size() {
return classes.size();
}

};
}

@Override
public String getDefaultDetailPane(IStructuredSelection selection) {
return SimpleDetailPane.ID;
}

}

我的 SimpleDetailPane.java 与示例中一样,只是“其他”颜色变为黄色。

最佳答案

表达式 View 由 org.eclipse.debug.internal.ui.views.expression.ExpressionView 提供它是 VariablesView 的子类.

org.eclipse.debug.ui.detailPaneFactories 的文档扩展点说:

This extension point allows clients to contribute custom renderings for the detail pane in the variables, registers, expressions, and breakpoints views

因此您应该能够为此 View 使用相同的扩展点。

关于java - 如何在Eclipse中的Expressions View 中正确实现自定义详细信息 Pane ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20641443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com