gpt4 book ai didi

java - Eclipse 项目属性/首选项页面 : How to find event of opening preference page in project property window(Eclipse)

转载 作者:行者123 更新时间:2023-12-01 13:57:35 24 4
gpt4 key购买 nike

我想在页面打开时初始化首选项页面上的某些字段值我希望每次在项目属性窗口(Eclipse)中打开页面时都有它。

最佳答案

尝试实现属性更改监听器。

这可能有帮助-

public class MyFieldEditorPreferencePage extends PropertyPage {
private Text text;

public void initialize() {
// TODO Auto-generated constructor stub
IProject project = (IProject) getElement().getAdapter(IProject.class);

final IPreferenceStore store = Activator
.getImpaktPreferenceStore(project);

store.addPropertyChangeListener(new IPropertyChangeListener() {

@Override
public void propertyChange(
org.eclipse.jface.util.PropertyChangeEvent event) {
// TODO Auto-generated method stub

// TODO Auto-generated method stub

if (text != null && !text.isDisposed())
text.setText(store.getString("key"));

}
});

setPreferenceStore(store);

}

@Override
protected Control createContents(Composite parent) {
// TODO Auto-generated method stub

initialize();
GridLayout layout = new GridLayout(1, false);
parent.setLayout(layout);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);

Composite container = new Composite(parent, 0);
container.setLayoutData(gridData);

GridLayout containerLayout = new GridLayout(2, false);
container.setLayout(containerLayout);
Label lbl = new Label(container, 0);
lbl.setText("Locale");

text = new Text(container, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

text.setText(getPreferenceStore().getString("impakt.properties.locale"));

return parent;
}

}

关于java - Eclipse 项目属性/首选项页面 : How to find event of opening preference page in project property window(Eclipse),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19543801/

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