Search in sources :

Example 1 with DBPPlatformLanguageManager

use of org.jkiss.dbeaver.model.app.DBPPlatformLanguageManager in project dbeaver by serge-rider.

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)

Example 2 with DBPPlatformLanguageManager

use of org.jkiss.dbeaver.model.app.DBPPlatformLanguageManager 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

DBException (org.jkiss.dbeaver.DBException)2 DBPPlatformLanguage (org.jkiss.dbeaver.model.app.DBPPlatformLanguage)2 DBPPlatformLanguageManager (org.jkiss.dbeaver.model.app.DBPPlatformLanguageManager)2 DBPPreferenceStore (org.jkiss.dbeaver.model.preferences.DBPPreferenceStore)2 PlatformLanguageDescriptor (org.jkiss.dbeaver.registry.language.PlatformLanguageDescriptor)2