Search in sources :

Example 1 with DBPPreferenceListener

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);
        }
    }
}
Also used : DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Example 2 with DBPPreferenceListener

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;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Color(org.eclipse.swt.graphics.Color) DisposeEvent(org.eclipse.swt.events.DisposeEvent) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Example 3 with DBPPreferenceListener

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;
}
Also used : PreferenceChangeEvent(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener.PreferenceChangeEvent) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) HexEditControl(org.jkiss.dbeaver.ui.editors.binary.HexEditControl) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Example 4 with DBPPreferenceListener

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);
            }
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener) FontData(org.eclipse.swt.graphics.FontData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FillLayout(org.eclipse.swt.layout.FillLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Example 5 with DBPPreferenceListener

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;
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore) HexEditControl(org.jkiss.dbeaver.ui.editors.binary.HexEditControl) DBPPreferenceListener(org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)

Aggregations

DBPPreferenceListener (org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)12 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)9 Color (org.eclipse.swt.graphics.Color)4 HexEditControl (org.jkiss.dbeaver.ui.editors.binary.HexEditControl)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 org.eclipse.jface.text (org.eclipse.jface.text)2 IContentAssistProcessor (org.eclipse.jface.text.contentassist.IContentAssistProcessor)2 IContentAssistant (org.eclipse.jface.text.contentassist.IContentAssistant)2 IContentFormatter (org.eclipse.jface.text.formatter.IContentFormatter)2 IFormattingStrategy (org.eclipse.jface.text.formatter.IFormattingStrategy)2 org.eclipse.jface.text.hyperlink (org.eclipse.jface.text.hyperlink)2 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)2 IInformationProvider (org.eclipse.jface.text.information.IInformationProvider)2 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)2 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)2 PresentationReconciler (org.eclipse.jface.text.presentation.PresentationReconciler)2 IReconciler (org.eclipse.jface.text.reconciler.IReconciler)2 MonoReconciler (org.eclipse.jface.text.reconciler.MonoReconciler)2 BufferedRuleBasedScanner (org.eclipse.jface.text.rules.BufferedRuleBasedScanner)2 DefaultDamagerRepairer (org.eclipse.jface.text.rules.DefaultDamagerRepairer)2