use of org.eclipse.jface.util.IPropertyChangeListener in project eclipse.platform.text by eclipse.
the class SourceViewerDecorationSupport method install.
/**
* Installs this decoration support on the given preference store. It assumes
* that this support has completely been configured.
*
* @param store the preference store
*/
public void install(IPreferenceStore store) {
fPreferenceStore = store;
if (fPreferenceStore != null) {
fPropertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
handlePreferenceStoreChanged(event);
}
};
fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
}
updateTextDecorations();
updateOverviewDecorations();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project eclipse.platform.text by eclipse.
the class LineNumberColumn method initialize.
/**
* Initializes the given line number ruler column from the preference store.
*/
private void initialize() {
final IPreferenceStore store = getPreferenceStore();
if (store == null)
return;
// initial set up
updateForegroundColor(store, fDelegate);
updateBackgroundColor(store, fDelegate);
updateLineNumbersVisibility(fDelegate);
updateQuickDiffVisibility(fDelegate);
updateCharacterMode(store, fDelegate);
updateRevisionRenderingMode(store, fDelegate);
updateRevisionAuthorVisibility(store, fDelegate);
updateRevisionIdVisibility(store, fDelegate);
Map<Object, AnnotationPreference> annotationPrefs = getAnnotationPreferenceMap();
// $NON-NLS-1$
final AnnotationPreference changedPref = annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffChange");
// $NON-NLS-1$
final AnnotationPreference addedPref = annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffAddition");
// $NON-NLS-1$
final AnnotationPreference deletedPref = annotationPrefs.get("org.eclipse.ui.workbench.texteditor.quickdiffDeletion");
updateChangedColor(changedPref, store, fDelegate);
updateAddedColor(addedPref, store, fDelegate);
updateDeletedColor(deletedPref, store, fDelegate);
fDelegate.redraw();
// listen to changes
fDispatcher = new PropertyEventDispatcher(store);
fDispatcher.addPropertyChangeListener(FG_COLOR_KEY, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateForegroundColor(store, fDelegate);
fDelegate.redraw();
}
});
IPropertyChangeListener backgroundHandler = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateBackgroundColor(store, fDelegate);
fDelegate.redraw();
}
};
fDispatcher.addPropertyChangeListener(BG_COLOR_KEY, backgroundHandler);
fDispatcher.addPropertyChangeListener(USE_DEFAULT_BG_KEY, backgroundHandler);
fDispatcher.addPropertyChangeListener(LINE_NUMBER_KEY, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
// only handle quick diff on/off information, but not ruler visibility (handled by AbstractDecoratedTextEditor)
updateLineNumbersVisibility(fDelegate);
}
});
fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateCharacterMode(store, fDelegate);
}
});
fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_RENDERING_MODE, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateRevisionRenderingMode(store, fDelegate);
}
});
fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_AUTHOR, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateRevisionAuthorVisibility(store, fDelegate);
}
});
fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.REVISION_RULER_SHOW_REVISION, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateRevisionIdVisibility(store, fDelegate);
}
});
fDispatcher.addPropertyChangeListener(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateQuickDiffVisibility(fDelegate);
}
});
if (changedPref != null) {
fDispatcher.addPropertyChangeListener(changedPref.getColorPreferenceKey(), new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateChangedColor(changedPref, store, fDelegate);
fDelegate.redraw();
}
});
}
if (addedPref != null) {
fDispatcher.addPropertyChangeListener(addedPref.getColorPreferenceKey(), new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateAddedColor(addedPref, store, fDelegate);
fDelegate.redraw();
}
});
}
if (deletedPref != null) {
fDispatcher.addPropertyChangeListener(deletedPref.getColorPreferenceKey(), new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
updateDeletedColor(deletedPref, store, fDelegate);
fDelegate.redraw();
}
});
}
}
use of org.eclipse.jface.util.IPropertyChangeListener in project knime-core by knime.
the class BorderStyleDialog method createColorSelector.
private void createColorSelector(final Composite parent) {
Composite panel = new Composite(parent, SWT.FILL);
GridData gData = new GridData(GridData.FILL_HORIZONTAL);
panel.setLayoutData(gData);
panel.setLayout(new GridLayout(2, false));
Label msg = new Label(panel, SWT.LEFT);
msg.setText("Border color (click to change):");
msg.setLayoutData(gData);
final ColorSelector sel = new ColorSelector(panel);
sel.setColorValue(m_defColor.getRGB());
sel.addListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
m_color = sel.getColorValue();
}
});
m_color = m_defColor.getRGB();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project mylyn.docs by eclipse.
the class WikiTextUiPlugin method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
preferencesListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
preferences = null;
}
};
getPreferenceStore().addPropertyChangeListener(preferencesListener);
}
use of org.eclipse.jface.util.IPropertyChangeListener in project mylyn.docs by eclipse.
the class MarkupEditor method createSourceViewer.
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
sourceViewerConfiguration.initializeDefaultFonts();
tabFolder = new CTabFolder(parent, SWT.BOTTOM);
{
sourceTab = new CTabItem(tabFolder, SWT.NONE);
updateSourceTabLabel();
viewer = new MarkupProjectionViewer(tabFolder, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles | SWT.WRAP);
sourceTab.setControl(((Viewer) viewer).getControl());
tabFolder.setSelection(sourceTab);
}
try {
previewTab = new CTabItem(tabFolder, SWT.NONE);
previewTab.setText(Messages.MarkupEditor_preview);
previewTab.setToolTipText(Messages.MarkupEditor_preview_tooltip);
browser = new Browser(tabFolder, SWT.NONE);
// bug 260479: open hyperlinks in a browser
browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
event.doit = false;
}
public void changing(LocationEvent event) {
// if it looks like an absolute URL
if (event.location.matches("([a-zA-Z]{3,8})://?.*")) {
// $NON-NLS-1$
// workaround for browser problem (bug 262043)
// $NON-NLS-1$
int idxOfSlashHash = event.location.indexOf("/#");
if (idxOfSlashHash != -1) {
// allow javascript-based scrolling to work
if (!event.location.startsWith("file:///#")) {
// $NON-NLS-1$
event.doit = false;
}
return;
}
// workaround end
event.doit = false;
try {
PlatformUI.getWorkbench().getBrowserSupport().createBrowser(// $NON-NLS-1$
"org.eclipse.ui.browser").openURL(new URL(event.location));
} catch (Exception e) {
new URLHyperlink(new Region(0, 1), event.location).open();
}
}
}
});
previewTab.setControl(browser);
} catch (SWTError e) {
// disable preview, the exception is probably due to the internal browser not being available
if (previewTab != null) {
previewTab.dispose();
previewTab = null;
}
logPreviewTabUnavailable(e);
}
tabFolder.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent selectionevent) {
widgetSelected(selectionevent);
}
public void widgetSelected(SelectionEvent selectionevent) {
if (isShowingPreview()) {
updatePreview();
}
}
});
viewer.getTextWidget().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
updateOutlineSelection();
}
});
viewer.getTextWidget().addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (isRelevantKeyCode(e.keyCode)) {
updateOutlineSelection();
}
}
private boolean isRelevantKeyCode(int keyCode) {
// for some reason not all key presses result in a selection change
switch(keyCode) {
case SWT.ARROW_DOWN:
case SWT.ARROW_LEFT:
case SWT.ARROW_RIGHT:
case SWT.ARROW_UP:
case SWT.PAGE_DOWN:
case SWT.PAGE_UP:
return true;
}
return false;
}
});
viewer.getTextWidget().addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
updateOutlineSelection();
}
});
IFocusService focusService = PlatformUI.getWorkbench().getService(IFocusService.class);
if (focusService != null) {
focusService.addFocusTracker(viewer.getTextWidget(), MarkupEditor.EDITOR_SOURCE_VIEWER);
}
viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
viewer.getTextWidget().setData(ISourceViewer.class.getName(), viewer);
getSourceViewerDecorationSupport(viewer);
updateDocument();
if (preferencesListener == null) {
preferencesListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if (viewer.getTextWidget() == null || viewer.getTextWidget().isDisposed()) {
return;
}
if (isFontPreferenceChange(event)) {
viewer.getTextWidget().getDisplay().asyncExec(new Runnable() {
public void run() {
reloadPreferences();
}
});
}
}
};
WikiTextUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(preferencesListener);
}
return viewer;
}
Aggregations