Search in sources :

Example 6 with PlatformLanguageDescriptor

use of org.jkiss.dbeaver.registry.language.PlatformLanguageDescriptor in project dbeaver by dbeaver.

the class PrefPageDatabaseUserInterface method performOk.

@Override
public boolean performOk() {
    DBPPreferenceStore store = DBWorkbench.getPlatform().getPreferenceStore();
    if (isStandalone) {
        store.setValue(DBeaverPreferences.UI_AUTO_UPDATE_CHECK, automaticUpdateCheck.getSelection());
    }
    store.setValue(ModelPreferences.NOTIFICATIONS_ENABLED, notificationsEnabled.getSelection());
    store.setValue(ModelPreferences.NOTIFICATIONS_CLOSE_DELAY_TIMEOUT, notificationsCloseDelay.getSelection());
    store.setValue(DBeaverPreferences.AGENT_LONG_OPERATION_NOTIFY, longOperationsCheck.getSelection());
    store.setValue(DBeaverPreferences.AGENT_LONG_OPERATION_TIMEOUT, longOperationsTimeout.getSelection());
    PrefUtils.savePreferenceStore(store);
    if (workspaceLanguage.getSelectionIndex() >= 0) {
        PlatformLanguageDescriptor language = PlatformLanguageRegistry.getInstance().getLanguages().get(workspaceLanguage.getSelectionIndex());
        try {
            DBPPlatformLanguage curLanguage = DBWorkbench.getPlatform().getLanguage();
            if (curLanguage != language) {
                ((DBPPlatformLanguageManager) DBWorkbench.getPlatform()).setPlatformLanguage(language);
                if (UIUtils.confirmAction(getShell(), "Restart " + GeneralUtils.getProductName(), "You need to restart " + GeneralUtils.getProductName() + " to perform actual language change.\nDo you want to restart?")) {
                    UIUtils.asyncExec(() -> PlatformUI.getWorkbench().restart());
                }
            }
        } catch (DBException e) {
            DBWorkbench.getPlatformUI().showError("Change language", "Can't switch language to " + language, e);
        }
    }
    return true;
}
Also used : DBPPlatformLanguageManager(org.jkiss.dbeaver.model.app.DBPPlatformLanguageManager) DBException(org.jkiss.dbeaver.DBException) DBPPlatformLanguage(org.jkiss.dbeaver.model.app.DBPPlatformLanguage) PlatformLanguageDescriptor(org.jkiss.dbeaver.registry.language.PlatformLanguageDescriptor) DBPPreferenceStore(org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)

Aggregations

DBPPlatformLanguage (org.jkiss.dbeaver.model.app.DBPPlatformLanguage)6 PlatformLanguageDescriptor (org.jkiss.dbeaver.registry.language.PlatformLanguageDescriptor)6 GridData (org.eclipse.swt.layout.GridData)3 DBException (org.jkiss.dbeaver.DBException)3 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)3 DBPPlatformLanguageManager (org.jkiss.dbeaver.model.app.DBPPlatformLanguageManager)2 List (java.util.List)1 SimpleContentProposalProvider (org.eclipse.jface.fieldassist.SimpleContentProposalProvider)1 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)1 PreferenceLinkArea (org.eclipse.ui.dialogs.PreferenceLinkArea)1 IWorkbenchPreferenceContainer (org.eclipse.ui.preferences.IWorkbenchPreferenceContainer)1 TextWithOpenFile (org.jkiss.dbeaver.ui.controls.TextWithOpenFile)1