use of org.jkiss.dbeaver.model.preferences.DBPPreferenceListener in project dbeaver by serge-rider.
the class SimplePreferenceStore method firePropertyChangeEvent.
@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
final Object[] finalListeners = getListeners();
// Do we need to fire an event.
if (finalListeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) {
final PreferenceChangeEvent pe = new PreferenceChangeEvent(this, name, oldValue, newValue);
for (int i = 0; i < finalListeners.length; ++i) {
final DBPPreferenceListener l = (DBPPreferenceListener) finalListeners[i];
l.preferenceChange(pe);
}
}
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceListener in project dbeaver by serge-rider.
the class SQLEditorSourceViewerConfiguration method getContentAssistant.
/**
* Creates, initializes, and returns the ContentAssistant to use with this editor.
*/
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
DBPPreferenceStore store = editor.getActivePreferenceStore();
final DBPPreferenceStore configStore = store;
final SQLContentAssistant assistant = new SQLContentAssistant();
assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
// Set content assist processors for various content types.
if (completionProcessor != null) {
assistant.setContentAssistProcessor(completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
}
// Configure how content assist information will appear.
assistant.enableAutoActivation(store.getBoolean(SQLPreferenceConstants.ENABLE_AUTO_ACTIVATION));
assistant.setAutoActivationDelay(store.getInt(SQLPreferenceConstants.AUTO_ACTIVATION_DELAY));
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
//In the future, a preference page will be added to customize foreground and background.
Color foreground = new Color(DBeaverUI.getDisplay(), 0, 0, 0);
Color background = new Color(DBeaverUI.getDisplay(), 255, 255, 255);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.setContextInformationPopupForeground(foreground);
assistant.setContextInformationPopupBackground(background);
//Set auto insert mode.
assistant.enableAutoInsert(store.getBoolean(SQLPreferenceConstants.INSERT_SINGLE_PROPOSALS_AUTO));
assistant.setShowEmptyList(true);
final DBPPreferenceListener prefListener = new DBPPreferenceListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
switch(event.getProperty()) {
case SQLPreferenceConstants.ENABLE_AUTO_ACTIVATION:
assistant.enableAutoActivation(configStore.getBoolean(SQLPreferenceConstants.ENABLE_AUTO_ACTIVATION));
break;
case SQLPreferenceConstants.AUTO_ACTIVATION_DELAY:
assistant.setAutoActivationDelay(configStore.getInt(SQLPreferenceConstants.AUTO_ACTIVATION_DELAY));
break;
case SQLPreferenceConstants.INSERT_SINGLE_PROPOSALS_AUTO:
assistant.enableAutoInsert(configStore.getBoolean(SQLPreferenceConstants.INSERT_SINGLE_PROPOSALS_AUTO));
break;
}
}
};
configStore.addPropertyChangeListener(prefListener);
editor.getTextViewer().getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
configStore.removePropertyChangeListener(prefListener);
}
});
return assistant;
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceListener in project dbeaver by dbeaver.
the class BinaryPanelEditor method createControl.
@Override
public HexEditControl createControl(IValueController valueController) {
HexEditControl hControl = new HexEditControl(valueController.getEditPlaceholder(), SWT.BORDER);
DBPPreferenceListener preferencesChangeListener = new DBPPreferenceListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (HexPreferencesPage.PROP_DEF_WIDTH.equals(event.getProperty())) {
String defValue = (String) event.getNewValue();
hControl.setDefWidth(Integer.valueOf(defValue));
}
}
};
DBPPreferenceStore store = DBeaverCore.getGlobalPreferenceStore();
store.addPropertyChangeListener(preferencesChangeListener);
return hControl;
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceListener in project dbeaver by serge-rider.
the class BinaryEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
IStorage storage = EditorUtils.getStorageFromInput(getEditorInput());
manager = new HexManager();
manager.setTextFont(HexPreferencesPage.getPrefFontData());
manager.setDefWidth(HexPreferencesPage.getDefaultWidth());
manager.setMenuListener(this);
int editorStyle = SWT.NONE;
if (storage != null && storage.isReadOnly()) {
editorStyle = SWT.READ_ONLY;
}
manager.createEditorPart(parent, editorStyle);
FillLayout fillLayout = new FillLayout();
parent.setLayout(fillLayout);
loadBinaryContent();
// Register any global actions with the site's IActionBars.
IActionBars bars = getEditorSite().getActionBars();
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_UNDO);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_REDO);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_CUT);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_COPY);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_PASTE);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_DELETE);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_SELECT_ALL);
createEditorAction(bars, IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE);
createEditorAction(bars, ITextEditorActionConstants.GOTO_LINE);
manager.addListener(new Listener() {
@Override
public void handleEvent(Event event) {
firePropertyChange(PROP_DIRTY);
updateActionsStatus();
}
});
bars.updateActionBars();
preferencesChangeListener = new DBPPreferenceListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (HexPreferencesPage.PROP_FONT_DATA.equals(event.getProperty())) {
manager.setTextFont((FontData) event.getNewValue());
}
if (HexPreferencesPage.PROP_DEF_WIDTH.equals(event.getProperty())) {
manager.setDefWidth((String) event.getNewValue());
}
}
};
DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
store.addPropertyChangeListener(preferencesChangeListener);
manager.addLongSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (selectionListeners == null)
return;
long[] longSelection = HexEditControl.getLongSelection(e);
SelectionChangedEvent event = new SelectionChangedEvent(BinaryEditor.this, new StructuredSelection(new Object[] { longSelection[0], longSelection[1] }));
for (ISelectionChangedListener selectionListener : selectionListeners) {
selectionListener.selectionChanged(event);
}
}
});
}
use of org.jkiss.dbeaver.model.preferences.DBPPreferenceListener in project dbeaver by serge-rider.
the class BinaryPanelEditor method createControl.
@Override
public HexEditControl createControl(IValueController valueController) {
HexEditControl hControl = new HexEditControl(valueController.getEditPlaceholder(), SWT.BORDER);
DBPPreferenceListener preferencesChangeListener = new DBPPreferenceListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (HexPreferencesPage.PROP_DEF_WIDTH.equals(event.getProperty())) {
String defValue = (String) event.getNewValue();
hControl.setDefWidth(Integer.valueOf(defValue));
}
}
};
DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
store.addPropertyChangeListener(preferencesChangeListener);
return hControl;
}
Aggregations