Search in sources :

Example 61 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by serge-rider.

the class PrefPageDataFormat method performDefaults.

@Override
protected void performDefaults() {
    DBPPreferenceStore targetPreferenceStore = getTargetPreferenceStore();
    clearPreferences(targetPreferenceStore);
    formatterProfile = null;
    loadPreferences(targetPreferenceStore);
    reloadSample();
    super.performDefaults();
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 62 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by serge-rider.

the class BinaryEditor method dispose.

/**
 * Removes preferences-changed listener
 *
 * @see WorkbenchPart#dispose()
 */
@Override
public void dispose() {
    if (manager != null) {
        manager.dispose();
        manager = null;
    }
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    store.removePropertyChangeListener(preferencesChangeListener);
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    super.dispose();
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 63 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore 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 64 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by serge-rider.

the class HexPreferencesPage method performOk.

/**
 * @see HexPreferencesPage#performOk()
 */
@Override
public boolean performOk() {
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    FontData fontData = preferences.getFontData();
    store.setValue(HexEditorPreferences.HEX_FONT_NAME, fontData.getName());
    store.setValue(HexEditorPreferences.HEX_FONT_STYLE, fontData.getStyle());
    store.setValue(HexEditorPreferences.HEX_FONT_SIZE, fontData.getHeight());
    store.firePropertyChangeEvent(PROP_FONT_DATA, null, fontData);
    store.setValue(HexEditorPreferences.HEX_DEF_WIDTH, preferences.getDefWidth());
    store.firePropertyChangeEvent(PROP_DEF_WIDTH, 0, preferences.getDefWidth());
    PrefUtils.savePreferenceStore(store);
    return true;
}
Also used : FontData(org.eclipse.swt.graphics.FontData) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Example 65 with DBPPreferenceStore

use of org.jkiss.dbeaver.model.preferences.DBPPreferenceStore in project dbeaver by serge-rider.

the class HexPreferencesPage method getDefaultWidth.

public static String getDefaultWidth() {
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    String defWidth = store.getString(HexEditorPreferences.HEX_DEF_WIDTH);
    return CommonUtils.isEmpty(defWidth) ? "8" : defWidth;
}
Also used : DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Aggregations

DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)201 DBPPreferenceListener (org.jkiss.dbeaver.model.preferences.DBPPreferenceListener)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)10 ExecutionException (org.eclipse.core.commands.ExecutionException)8 GridData (org.eclipse.swt.layout.GridData)8 NotNull (org.jkiss.code.NotNull)8 BundlePreferenceStore (org.jkiss.dbeaver.model.impl.preferences.BundlePreferenceStore)8 Color (org.eclipse.swt.graphics.Color)6 FontData (org.eclipse.swt.graphics.FontData)6 DBException (org.jkiss.dbeaver.DBException)6 DBDDisplayFormat (org.jkiss.dbeaver.model.data.DBDDisplayFormat)6 QMObjectType (org.jkiss.dbeaver.model.qm.QMObjectType)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 AbstractJob (org.jkiss.dbeaver.model.runtime.AbstractJob)4 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)4