Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Seelmann <mail@stefan-seelmann.de>2021-05-24 21:22:48 +0300
committerStefan Seelmann <mail@stefan-seelmann.de>2021-05-24 21:22:48 +0300
commitaf6f20370145f1adde3fb187eeeee449f7150256 (patch)
treef337673d16c3e9aab4f1d4d21462ff6fc5ea0a0c
parentbb684b4ba0ac8ef775eb91ecfa053c7ed58139cd (diff)
Use new preferenes API
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java105
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java19
-rw-r--r--plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/LdifSearchLogger.java13
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java100
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java103
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java11
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java5
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java11
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java11
-rw-r--r--plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java9
10 files changed, 246 insertions, 141 deletions
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java
index ad6af27de..e9d861eea 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePlugin.java
@@ -41,7 +41,11 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.framework.BundleContext;
+import org.osgi.service.prefs.BackingStoreException;
/**
@@ -95,7 +99,6 @@ public class ConnectionCorePlugin extends Plugin
/** The plugin properties */
private PropertyResourceBundle properties;
-
/**
* The constructor
*/
@@ -481,7 +484,8 @@ public class ConnectionCorePlugin extends Plugin
connectionListeners = new ArrayList<IConnectionListener>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint( "org.apache.directory.studio.connectionlistener" ); //$NON-NLS-1$
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint( "org.apache.directory.studio.connectionlistener" ); //$NON-NLS-1$
IConfigurationElement[] members = extensionPoint.getConfigurationElements();
for ( IConfigurationElement member : members )
{
@@ -494,7 +498,8 @@ public class ConnectionCorePlugin extends Plugin
{
getLog().log(
new Status( IStatus.ERROR, ConnectionCoreConstants.PLUGIN_ID, 1,
- Messages.error__unable_to_create_connection_listener + member.getAttribute( "class" ), e ) ); //$NON-NLS-1$
+ Messages.error__unable_to_create_connection_listener + member.getAttribute( "class" ), //$NON-NLS-1$
+ e ) );
}
}
}
@@ -568,4 +573,98 @@ public class ConnectionCorePlugin extends Plugin
return defaultKrb5LoginModule;
}
+
+ public IEclipsePreferences getDefaultScopePreferences()
+ {
+ return DefaultScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
+ }
+
+
+ public void flushDefaultScopePreferences()
+ {
+ try
+ {
+ getDefaultScopePreferences().flush();
+ }
+ catch ( BackingStoreException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ public IEclipsePreferences getInstanceScopePreferences()
+ {
+ return InstanceScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
+ }
+
+
+ public void flushInstanceScopePreferences()
+ {
+ try
+ {
+ getInstanceScopePreferences().flush();
+ }
+ catch ( BackingStoreException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ public int getModificationLogsFileCount()
+ {
+ return Platform.getPreferencesService().getInt( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, -1, null );
+ }
+
+
+ public int getModificationLogsFileSize()
+ {
+ return Platform.getPreferencesService().getInt( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, -1, null );
+ }
+
+
+ public boolean isModificationLogsEnabled()
+ {
+ return Platform.getPreferencesService().getBoolean( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, true, null );
+ }
+
+
+ public String getMModificationLogsMaskedAttributes()
+ {
+ return Platform.getPreferencesService().getString( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES, null, null );
+ }
+
+
+ public int getSearchLogsFileCount()
+ {
+ return Platform.getPreferencesService().getInt( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, -1, null );
+ }
+
+
+ public int getSearchLogsFileSize()
+ {
+ return Platform.getPreferencesService().getInt( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, -1, null );
+ }
+
+
+ public boolean isSearchRequestLogsEnabled()
+ {
+ return Platform.getPreferencesService().getBoolean( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, true, null );
+ }
+
+
+ public boolean isSearchResultEntryLogsEnabled()
+ {
+ return Platform.getPreferencesService().getBoolean( ConnectionCoreConstants.PLUGIN_ID,
+ ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, false, null );
+ }
+
}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java
index 7b4af455c..35f7d3d8f 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/ConnectionCorePreferencesInitializer.java
@@ -23,6 +23,7 @@ package org.apache.directory.studio.connection.core;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
/**
@@ -38,6 +39,7 @@ public class ConnectionCorePreferencesInitializer extends AbstractPreferenceInit
public void initializeDefaultPreferences()
{
Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences();
+ IEclipsePreferences defaultPreferences = ConnectionCorePlugin.getDefault().getDefaultScopePreferences();
// LDAP connection settings
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_VALIDATE_CERTIFICATES, true );
@@ -46,18 +48,21 @@ public class ConnectionCorePreferencesInitializer extends AbstractPreferenceInit
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_USE_KRB5_SYSTEM_PROPERTIES, false );
// Modification Logs
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, true );
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, 10 );
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, 100 );
+ defaultPreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, true );
+ defaultPreferences.put( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES, "" );
+ defaultPreferences.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, 10 );
+ defaultPreferences.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, 100 );
// Search Logs
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, true );
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, false );
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, 10 );
- preferences.setDefault( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, 100 );
+ defaultPreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, true );
+ defaultPreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, false );
+ defaultPreferences.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, 10 );
+ defaultPreferences.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, 100 );
// Connections Passwords Keystore
preferences.setDefault( ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE,
ConnectionCoreConstants.PREFERENCE_CONNECTIONS_PASSWORDS_KEYSTORE_OFF );
+
+ ConnectionCorePlugin.getDefault().flushDefaultScopePreferences();
}
}
diff --git a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/LdifSearchLogger.java b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/LdifSearchLogger.java
index 2e04f9e92..0e4493857 100644
--- a/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/LdifSearchLogger.java
+++ b/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/LdifSearchLogger.java
@@ -66,7 +66,6 @@ import org.apache.directory.studio.ldifparser.model.lines.LdifCommentLine;
import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
import org.apache.directory.studio.ldifparser.model.lines.LdifLineBase;
import org.apache.directory.studio.ldifparser.model.lines.LdifSepLine;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -472,8 +471,7 @@ public class LdifSearchLogger implements ILdapLogger
*/
private boolean isSearchRequestLogEnabled()
{
- return Platform.getPreferencesService().getBoolean( ConnectionCoreConstants.PLUGIN_ID,
- ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, true, null );
+ return ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled();
}
@@ -484,8 +482,7 @@ public class LdifSearchLogger implements ILdapLogger
*/
private boolean isSearchResultEntryLogEnabled()
{
- return Platform.getPreferencesService().getBoolean( ConnectionCoreConstants.PLUGIN_ID,
- ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, false, null );
+ return ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled();
}
@@ -496,8 +493,7 @@ public class LdifSearchLogger implements ILdapLogger
*/
private int getFileCount()
{
- return Platform.getPreferencesService().getInt( ConnectionCoreConstants.PLUGIN_ID,
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, 10, null );
+ return ConnectionCorePlugin.getDefault().getSearchLogsFileCount();
}
@@ -508,8 +504,7 @@ public class LdifSearchLogger implements ILdapLogger
*/
private int getFileSizeInKb()
{
- return Platform.getPreferencesService().getInt( ConnectionCoreConstants.PLUGIN_ID,
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, 100, null );
+ return ConnectionCorePlugin.getDefault().getSearchLogsFileSize();
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java
index 3765c26c8..3694014de 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/ModificationLogsPreferencePage.java
@@ -25,9 +25,8 @@ import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -51,7 +50,6 @@ public class ModificationLogsPreferencePage extends PreferencePage implements IW
private Text logFileSizeText;
private Text maskedAttributesText;
-
/**
* Creates a new instance of ModificationLogsPreferencePage.
*/
@@ -82,8 +80,6 @@ public class ModificationLogsPreferencePage extends PreferencePage implements IW
BaseWidgetUtils.createSpacer( composite, 1 );
enableModificationLogging = BaseWidgetUtils.createCheckbox( composite, Messages
.getString( "ModificationLogsPreferencePage.EnableModificationLogs" ), 1 ); //$NON-NLS-1$
- enableModificationLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ) );
BaseWidgetUtils.createSpacer( composite, 1 );
BaseWidgetUtils.createSpacer( composite, 1 );
@@ -92,8 +88,6 @@ public class ModificationLogsPreferencePage extends PreferencePage implements IW
1 ), Messages.getString( "ModificationLogsPreferencePage.MaskedAttributes" ), 1 ); //$NON-NLS-1$
Composite maskedAttributesComposite = BaseWidgetUtils.createColumnContainer( maskedAttributesGroup, 1, 1 );
maskedAttributesText = BaseWidgetUtils.createText( maskedAttributesComposite, "", 1 ); //$NON-NLS-1$
- maskedAttributesText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES ) );
String maskedAttributesHelp = Messages.getString( "ModificationLogsPreferencePage.CommaSeparatedList" ); //$NON-NLS-1$
BaseWidgetUtils.createWrappedLabel( maskedAttributesComposite, maskedAttributesHelp, 1 );
@@ -105,61 +99,70 @@ public class ModificationLogsPreferencePage extends PreferencePage implements IW
Composite rotateComposite = BaseWidgetUtils.createColumnContainer( rotateGroup, 5, 1 );
BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "ModificationLogsPreferencePage.Use" ), 1 ); //$NON-NLS-1$
logFileCountText = BaseWidgetUtils.createText( rotateComposite, "", 3, 1 ); //$NON-NLS-1$
- logFileCountText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT ) );
- logFileCountText.addVerifyListener( new VerifyListener()
- {
- public void verifyText( VerifyEvent e )
+ logFileCountText.addVerifyListener( e -> {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+ {
+ e.doit = false;
+ }
+ if ( "".equals( logFileCountText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
{
- if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
- {
- e.doit = false;
- }
- if ( "".equals( logFileCountText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- {
- e.doit = false;
- }
+ e.doit = false;
}
} );
+ logFileCountText.addModifyListener( e -> validate() );
BaseWidgetUtils.createLabel( rotateComposite, Messages
.getString( "ModificationLogsPreferencePage.LogFilesEach" ), 1 ); //$NON-NLS-1$
logFileSizeText = BaseWidgetUtils.createText( rotateComposite, "", 5, 1 ); //$NON-NLS-1$
- logFileSizeText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE ) );
- logFileSizeText.addVerifyListener( new VerifyListener()
- {
- public void verifyText( VerifyEvent e )
+ logFileSizeText.addVerifyListener( e -> {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
{
- if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
- {
- e.doit = false;
- }
- if ( "".equals( logFileSizeText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- {
- e.doit = false;
- }
+ e.doit = false;
+ }
+ if ( "".equals( logFileSizeText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ e.doit = false;
}
} );
+ logFileSizeText.addModifyListener( e -> validate() );
BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "ModificationLogsPreferencePage.KB" ), 1 ); //$NON-NLS-1$
+ setValues();
+
applyDialogFont( composite );
return composite;
}
+ private void setValues()
+ {
+ enableModificationLogging.setSelection( ConnectionCorePlugin.getDefault().isModificationLogsEnabled() );
+ maskedAttributesText.setText( ConnectionCorePlugin.getDefault().getMModificationLogsMaskedAttributes() );
+ logFileCountText.setText( "" + ConnectionCorePlugin.getDefault().getModificationLogsFileCount() );
+ logFileSizeText.setText( "" + ConnectionCorePlugin.getDefault().getModificationLogsFileSize() );
+ }
+
+
+ public void validate()
+ {
+ setValid( logFileCountText.getText().matches( "[0-9]+" ) && logFileSizeText.getText().matches( "[0-9]+" ) );
+ }
+
+
/**
* {@inheritDoc}
*/
public boolean performOk()
{
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, enableModificationLogging.getSelection() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, logFileCountText.getText() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, logFileSizeText.getText() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES, maskedAttributesText.getText() );
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE,
+ enableModificationLogging.getSelection() );
+ instancePreferences.put( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES,
+ maskedAttributesText.getText() );
+ instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT,
+ Integer.parseInt( logFileCountText.getText() ) );
+ instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE,
+ Integer.parseInt( logFileSizeText.getText() ) );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
return true;
}
@@ -169,14 +172,13 @@ public class ModificationLogsPreferencePage extends PreferencePage implements IW
*/
protected void performDefaults()
{
- enableModificationLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getDefaultBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ) );
- logFileCountText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT ) );
- logFileSizeText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE ) );
- maskedAttributesText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES ) );
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE );
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES );
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT );
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
+ setValues();
super.performDefaults();
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java
index 9cfe2349c..1697782a0 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/dialogs/preferences/SearchLogsPreferencePage.java
@@ -25,9 +25,8 @@ import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -51,7 +50,6 @@ public class SearchLogsPreferencePage extends PreferencePage implements IWorkben
private Text logFileCountText;
private Text logFileSizeText;
-
/**
* Creates a new instance of SearchResultEditorPreferencePage.
*/
@@ -82,73 +80,79 @@ public class SearchLogsPreferencePage extends PreferencePage implements IWorkben
BaseWidgetUtils.createSpacer( composite, 1 );
enableSearchRequestLogging = BaseWidgetUtils.createCheckbox( composite, Messages
.getString( "SearchLogsPreferencePage.EnableRequestLogs" ), 1 ); //$NON-NLS-1$
- enableSearchRequestLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
- ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) );
enableSearchResultEntryLogging = BaseWidgetUtils.createCheckbox( composite, Messages
.getString( "SearchLogsPreferencePage.EnableResultLogs" ), 1 ); //$NON-NLS-1$
- enableSearchResultEntryLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) );
Group rotateGroup = BaseWidgetUtils.createGroup( BaseWidgetUtils.createColumnContainer( composite, 1, 1 ),
Messages.getString( "SearchLogsPreferencePage.LogFileRotation" ), 1 ); //$NON-NLS-1$
Composite rotateComposite = BaseWidgetUtils.createColumnContainer( rotateGroup, 5, 1 );
BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.Use" ), 1 ); //$NON-NLS-1$
logFileCountText = BaseWidgetUtils.createText( rotateComposite, "", 3, 1 ); //$NON-NLS-1$
- logFileCountText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT ) );
- logFileCountText.addVerifyListener( new VerifyListener()
- {
- public void verifyText( VerifyEvent e )
+ logFileCountText.addVerifyListener( e -> {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
+ {
+ e.doit = false;
+ }
+ if ( "".equals( logFileCountText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
{
- if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
- {
- e.doit = false;
- }
- if ( "".equals( logFileCountText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- {
- e.doit = false;
- }
+ e.doit = false;
}
} );
- BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.LogFilesEach" ), 1 ); //$NON-NLS-1$
+ logFileCountText.addModifyListener( e -> validate() );
+ BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.LogFilesEach" ), //$NON-NLS-1$
+ 1 );
logFileSizeText = BaseWidgetUtils.createText( rotateComposite, "", 5, 1 ); //$NON-NLS-1$
- logFileSizeText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE ) );
- logFileSizeText.addVerifyListener( new VerifyListener()
- {
- public void verifyText( VerifyEvent e )
+ logFileSizeText.addVerifyListener( e -> {
+ if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
{
- if ( !e.text.matches( "[0-9]*" ) ) //$NON-NLS-1$
- {
- e.doit = false;
- }
- if ( "".equals( logFileSizeText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
- {
- e.doit = false;
- }
+ e.doit = false;
+ }
+ if ( "".equals( logFileSizeText.getText() ) && e.text.matches( "[0]" ) ) //$NON-NLS-1$ //$NON-NLS-2$
+ {
+ e.doit = false;
}
} );
+ logFileSizeText.addModifyListener( e -> validate() );
BaseWidgetUtils.createLabel( rotateComposite, Messages.getString( "SearchLogsPreferencePage.KB" ), 1 ); //$NON-NLS-1$
+ setValues();
+
applyDialogFont( composite );
return composite;
}
+ private void setValues()
+ {
+ enableSearchRequestLogging.setSelection( ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled() );
+ enableSearchResultEntryLogging
+ .setSelection( ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled() );
+ logFileCountText.setText( "" + ConnectionCorePlugin.getDefault().getSearchLogsFileCount() );
+ logFileSizeText.setText( "" + ConnectionCorePlugin.getDefault().getSearchLogsFileSize() );
+ }
+
+
+ public void validate()
+ {
+ setValid( logFileCountText.getText().matches( "[0-9]+" ) && logFileSizeText.getText().matches( "[0-9]+" ) );
+ }
+
+
/**
* {@inheritDoc}
*/
public boolean performOk()
{
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, enableSearchRequestLogging.getSelection() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE,
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE,
+ enableSearchRequestLogging.getSelection() );
+ instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE,
enableSearchResultEntryLogging.getSelection() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, logFileCountText.getText() );
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, logFileSizeText.getText() );
+ instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT,
+ Integer.parseInt( logFileCountText.getText() ) );
+ instancePreferences.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE,
+ Integer.parseInt( logFileSizeText.getText() ) );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
return true;
}
@@ -158,14 +162,13 @@ public class SearchLogsPreferencePage extends PreferencePage implements IWorkben
*/
protected void performDefaults()
{
- enableSearchRequestLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getDefaultBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) );
- enableSearchResultEntryLogging.setSelection( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getDefaultBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) );
- logFileCountText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT ) );
- logFileSizeText.setText( ConnectionCorePlugin.getDefault().getPluginPreferences().getDefaultString(
- ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE ) );
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE );
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE );
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT );
+ instancePreferences.remove( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
+ setValues();
super.performDefaults();
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java
index 3d53069aa..b36dfb099 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/EnableModificationLogsAction.java
@@ -23,6 +23,7 @@ package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.action.Action;
@@ -42,8 +43,7 @@ public class EnableModificationLogsAction extends Action
super( Messages.getString( "EnableModificationLogsAction.EnableModificationLogs" ), AS_CHECK_BOX ); //$NON-NLS-1$
setToolTipText( getText() );
setEnabled( true );
- setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ) );
+ setChecked( ConnectionCorePlugin.getDefault().isModificationLogsEnabled() );
}
@@ -52,9 +52,10 @@ public class EnableModificationLogsAction extends Action
*/
public void run()
{
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE, super.isChecked() );
- ConnectionCorePlugin.getDefault().savePluginPreferences();
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE,
+ super.isChecked() );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
}
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
index 35a1f959f..1497a5d8f 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/modificationlogs/ModificationLogsViewActionGroup.java
@@ -24,7 +24,6 @@ package org.apache.directory.studio.ldapbrowser.ui.views.modificationlogs;
import java.util.HashMap;
import java.util.Map;
-import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager;
import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.ModificationLogsViewActionProxy;
@@ -144,8 +143,8 @@ public class ModificationLogsViewActionGroup implements ActionHandlerManager, IM
{
public void menuAboutToShow( IMenuManager manager )
{
- enableModificationLogsAction.setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getBoolean( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_ENABLE ) );
+ enableModificationLogsAction
+ .setChecked( ConnectionCorePlugin.getDefault().isModificationLogsEnabled() );
}
} );
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java
index 3a8b42e08..5557b0101 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchRequestLogsAction.java
@@ -23,6 +23,7 @@ package org.apache.directory.studio.ldapbrowser.ui.views.searchlogs;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.action.Action;
@@ -42,8 +43,7 @@ public class EnableSearchRequestLogsAction extends Action
super( Messages.getString( "EnableSearchRequestLogsAction.EnableSearchRequestLogs" ), AS_CHECK_BOX ); //$NON-NLS-1$
setToolTipText( getText() );
setEnabled( true );
- setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
- ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) );
+ setChecked( ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled() );
}
@@ -52,9 +52,10 @@ public class EnableSearchRequestLogsAction extends Action
*/
public void run()
{
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE, super.isChecked() );
- ConnectionCorePlugin.getDefault().savePluginPreferences();
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE,
+ super.isChecked() );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
}
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java
index 8cb55ddb9..74afd1c1d 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/EnableSearchResultEntryLogsAction.java
@@ -23,6 +23,7 @@ package org.apache.directory.studio.ldapbrowser.ui.views.searchlogs;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.action.Action;
@@ -42,8 +43,7 @@ public class EnableSearchResultEntryLogsAction extends Action
super( Messages.getString( "EnableSearchResultEntryLogsAction.EnableSearchResultLogs" ), AS_CHECK_BOX ); //$NON-NLS-1$
setToolTipText( getText() );
setEnabled( true );
- setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences().getBoolean(
- ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) );
+ setChecked( ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled() );
}
@@ -52,9 +52,10 @@ public class EnableSearchResultEntryLogsAction extends Action
*/
public void run()
{
- ConnectionCorePlugin.getDefault().getPluginPreferences().setValue(
- ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE, super.isChecked() );
- ConnectionCorePlugin.getDefault().savePluginPreferences();
+ IEclipsePreferences instancePreferences = ConnectionCorePlugin.getDefault().getInstanceScopePreferences();
+ instancePreferences.putBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE,
+ super.isChecked() );
+ ConnectionCorePlugin.getDefault().flushInstanceScopePreferences();
}
}
diff --git a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java
index 2038596b7..49293fbac 100644
--- a/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java
+++ b/plugins/ldapbrowser.ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/views/searchlogs/SearchLogsViewActionGroup.java
@@ -24,7 +24,6 @@ package org.apache.directory.studio.ldapbrowser.ui.views.searchlogs;
import java.util.HashMap;
import java.util.Map;
-import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.ldapbrowser.common.actions.proxy.ActionHandlerManager;
import org.apache.directory.studio.ldapbrowser.ui.actions.proxy.SearchLogsViewActionProxy;
@@ -145,10 +144,10 @@ public class SearchLogsViewActionGroup implements ActionHandlerManager, IMenuLis
{
public void menuAboutToShow( IMenuManager manager )
{
- enableSearchRequestLogsAction.setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHREQUESTLOGS_ENABLE ) );
- enableSearchResultEntryLogsAction.setChecked( ConnectionCorePlugin.getDefault().getPluginPreferences()
- .getBoolean( ConnectionCoreConstants.PREFERENCE_SEARCHRESULTENTRYLOGS_ENABLE ) );
+ enableSearchRequestLogsAction
+ .setChecked( ConnectionCorePlugin.getDefault().isSearchRequestLogsEnabled() );
+ enableSearchResultEntryLogsAction
+ .setChecked( ConnectionCorePlugin.getDefault().isSearchResultEntryLogsEnabled() );
}
} );
}