本文整理汇总了Java中org.eclipse.jface.preference.IPreferenceStore.addPropertyChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java IPreferenceStore.addPropertyChangeListener方法的具体用法?Java IPreferenceStore.addPropertyChangeListener怎么用?Java IPreferenceStore.addPropertyChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.preference.IPreferenceStore
的用法示例。
在下文中一共展示了IPreferenceStore.addPropertyChangeListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DbStorePicker
import org.eclipse.jface.preference.IPreferenceStore; //导入方法依赖的package包/类
public DbStorePicker(Composite parent, final IPreferenceStore prefStore,
boolean useFileSources, boolean useDirSources, boolean onlyCombo) {
super(parent, SWT.NONE);
this.useFileSources = useFileSources;
this.useDirSources = useDirSources;
this.lrm = new LocalResourceManager(JFaceResources.getResources(), this);
this.prefStore = prefStore;
GridLayout gl = new GridLayout(onlyCombo ? 1 : 3, false);
gl.marginWidth = gl.marginHeight = 0;
setLayout(gl);
if (!onlyCombo) {
new Label(this, SWT.NONE).setText(useFileSources || useDirSources ?
Messages.DbStorePicker_db_schema_source : Messages.DbStorePicker_db_connection);
}
cmbDbNames = new ComboViewer(this, SWT.READ_ONLY | SWT.DROP_DOWN);
cmbDbNames.setContentProvider(ArrayContentProvider.getInstance());
cmbDbNames.setLabelProvider(new DbStoreLabelProvider());
cmbDbNames.addSelectionChangedListener(new DbStoreSelectionListener());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = new PixelConverter(cmbDbNames.getControl()).convertWidthInCharsToPixels(26);
cmbDbNames.getControl().setLayoutData(gd);
if (!onlyCombo) {
Button btnEditStore = new Button(this, SWT.PUSH);
btnEditStore.setImage(lrm.createImage(ImageDescriptor.createFromURL(
Activator.getContext().getBundle().getResource(FILE.ICONEDIT))));
btnEditStore.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferenceDialog prefDialog = PreferencesUtil.createPreferenceDialogOn(
getShell(), PREF_PAGE.DB_STORE, null, null);
if (prefDialog.open() == PreferenceDialog.OK) {
loadStore();
}
}
});
}
final IPropertyChangeListener dbStoreChangeListener = (PropertyChangeEvent event) -> {
if (PREF.DB_STORE.equals(event.getProperty())
&& !Objects.equals(event.getNewValue(), event.getOldValue())) {
UiSync.exec(DbStorePicker.this, () -> {
if (!isDisposed()) {
loadStore();
}
});
}
};
prefStore.addPropertyChangeListener(dbStoreChangeListener);
cmbDbNames.getControl().addDisposeListener(e -> prefStore
.removePropertyChangeListener(dbStoreChangeListener));
if (useDirSources) {
// load projects in ctor for now, Workspace listener and dynamic list may be added later
IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < MAX_FILES_HISTORY && i < projs.length; ++i) {
try {
if (projs[i].isOpen() && projs[i].hasNature(NATURE.ID)) {
this.projects.add(projs[i].getLocation().toFile());
}
} catch (CoreException ex) {
Log.log(ex);
}
}
}
loadStore();
}