directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1304371 - in /directory/studio/trunk/plugins: common.ui/src/main/java/org/apache/directory/studio/common/ui/ connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/ ldapbrowser.common/src/main/java/org/apache/directo...
Date Fri, 23 Mar 2012 14:29:56 GMT
Author: pamarcelot
Date: Fri Mar 23 14:29:56 2012
New Revision: 1304371

URL: http://svn.apache.org/viewvc?rev=1304371&view=rev
Log:
Fix for DIRSTUDIO-797 (Two different 'HistoryUtils' classes should be merged into a single
one in 'common.ui' plugin).

Added:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/HistoryUtils.java
Removed:
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/HistoryUtils.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/HistoryUtils.java
Modified:
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
    directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/FileBrowserWidget.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/FilterWidget.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java

Added: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/HistoryUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/HistoryUtils.java?rev=1304371&view=auto
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/HistoryUtils.java
(added)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/HistoryUtils.java
Fri Mar 23 14:29:56 2012
@@ -0,0 +1,97 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.common.ui;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+
+
+/**
+ * The HistoryUtils are used to save and load the history of input fields.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class HistoryUtils
+{
+    /**
+     * Saves the the given value under the given key in the dialog settings.
+     *
+     * @param dialogSettings the dialog settings
+     * @param key the key
+     * @param value the value
+     */
+    public static void save( IDialogSettings dialogSettings, String key, String value )
+    {
+        if ( dialogSettings != null )
+        {
+
+            // get current history
+            String[] history = load( dialogSettings, key );
+            List<String> list = new ArrayList<String>( Arrays.asList( history
) );
+
+            // add new value or move to first position
+            if ( list.contains( value ) )
+            {
+                list.remove( value );
+            }
+            list.add( 0, value );
+
+            // check history size
+            while ( list.size() > 20 )
+            {
+                list.remove( list.size() - 1 );
+            }
+
+            // save
+            history = list.toArray( new String[list.size()] );
+            dialogSettings.put( key, history );
+        }
+    }
+
+
+    /**
+     * Loads the value of the given key from the dialog settings
+     *
+     * @param dialogSettings the dialog settings
+     * @param key the key
+     * @return the value
+     */
+    public static String[] load( IDialogSettings dialogSettings, String key )
+    {
+        if ( dialogSettings != null )
+        {
+            String[] history = dialogSettings.getArray( key );
+
+            if ( history == null )
+            {
+                history = new String[0];
+            }
+
+            return history;
+        }
+
+        return new String[0];
+    }
+}

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/AuthenticationParameterPage.java
Fri Mar 23 14:29:56 2012
@@ -26,6 +26,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.constants.SaslSecurityStrength;
 import org.apache.directory.shared.ldap.model.url.LdapUrl;
 import org.apache.directory.shared.ldap.model.url.LdapUrl.Extension;
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
@@ -37,9 +38,11 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.jobs.CheckBindRunnable;
 import org.apache.directory.studio.connection.ui.AbstractConnectionParameterPage;
 import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
+import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
 import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
@@ -326,7 +329,8 @@ public class AuthenticationParameterPage
         Composite composite = BaseWidgetUtils.createColumnContainer( group2, 3, 1 );
 
         BaseWidgetUtils.createLabel( composite, Messages.getString( "AuthenticationParameterPage.BindDNOrUser"
), 1 ); //$NON-NLS-1$
-        String[] dnHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_PRINCIPAL_HISTORY
);
+        String[] dnHistory = HistoryUtils.load( ConnectionUIPlugin.getDefault().getDialogSettings(),
+            ConnectionUIConstants.DIALOGSETTING_KEY_PRINCIPAL_HISTORY );
         bindPrincipalCombo = BaseWidgetUtils.createCombo( composite, dnHistory, -1, 2 );
 
         BaseWidgetUtils.createLabel( composite, Messages.getString( "AuthenticationParameterPage.BindPassword"
), 1 ); //$NON-NLS-1$
@@ -390,7 +394,8 @@ public class AuthenticationParameterPage
     private void createSaslControls()
     {
         BaseWidgetUtils.createLabel( saslComposite, Messages.getString( "AuthenticationParameterPage.SaslRealm"
), 1 ); //$NON-NLS-1$
-        String[] saslHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_REALM_HISTORY
);
+        String[] saslHistory = HistoryUtils.load( ConnectionUIPlugin.getDefault().getDialogSettings(),
+            ConnectionUIConstants.DIALOGSETTING_KEY_REALM_HISTORY );
         saslRealmText = BaseWidgetUtils.createCombo( saslComposite, saslHistory, -1, 1 );
 
         BaseWidgetUtils.createLabel( saslComposite, Messages.getString( "AuthenticationParameterPage.SaslQop"
), 1 ); //$NON-NLS-1$
@@ -825,10 +830,14 @@ public class AuthenticationParameterPage
      */
     public void saveDialogSettings()
     {
-        HistoryUtils.save( ConnectionUIConstants.DIALOGSETTING_KEY_PRINCIPAL_HISTORY, bindPrincipalCombo.getText()
);
+        IDialogSettings dialogSettings = ConnectionUIPlugin.getDefault().getDialogSettings();
+
+        HistoryUtils.save( dialogSettings, ConnectionUIConstants.DIALOGSETTING_KEY_PRINCIPAL_HISTORY,
+            bindPrincipalCombo.getText() );
         if ( getAuthenticationMethod().equals( AuthenticationMethod.SASL_DIGEST_MD5 ) )
         {
-            HistoryUtils.save( ConnectionUIConstants.DIALOGSETTING_KEY_REALM_HISTORY, saslRealmText.getText()
);
+            HistoryUtils.save( dialogSettings, ConnectionUIConstants.DIALOGSETTING_KEY_REALM_HISTORY,
+                saslRealmText.getText() );
         }
     }
 

Modified: directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
(original)
+++ directory/studio/trunk/plugins/connection.ui/src/main/java/org/apache/directory/studio/connection/ui/widgets/NetworkParameterPage.java
Fri Mar 23 14:29:56 2012
@@ -27,6 +27,7 @@ import java.util.Date;
 import org.apache.commons.lang.StringUtils;
 import org.apache.directory.shared.ldap.model.url.LdapUrl;
 import org.apache.directory.shared.ldap.model.url.LdapUrl.Extension;
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
@@ -37,8 +38,10 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.jobs.CheckNetworkParameterRunnable;
 import org.apache.directory.studio.connection.ui.AbstractConnectionParameterPage;
 import org.apache.directory.studio.connection.ui.ConnectionUIConstants;
+import org.apache.directory.studio.connection.ui.ConnectionUIPlugin;
 import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
@@ -220,13 +223,15 @@ public class NetworkParameterPage extend
         Group group = BaseWidgetUtils.createGroup( composite, Messages
             .getString( "NetworkParameterPage.NetworkParameter" ), 1 ); //$NON-NLS-1$
 
+        IDialogSettings dialogSettings = ConnectionUIPlugin.getDefault().getDialogSettings();
+
         Composite groupComposite = BaseWidgetUtils.createColumnContainer( group, 3, 1 );
         BaseWidgetUtils.createLabel( groupComposite, Messages.getString( "NetworkParameterPage.HostName"
), 1 ); //$NON-NLS-1$
-        String[] hostHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_HOST_HISTORY
);
+        String[] hostHistory = HistoryUtils.load( dialogSettings, ConnectionUIConstants.DIALOGSETTING_KEY_HOST_HISTORY
);
         hostCombo = BaseWidgetUtils.createCombo( groupComposite, hostHistory, -1, 2 );
 
         BaseWidgetUtils.createLabel( groupComposite, Messages.getString( "NetworkParameterPage.Port"
), 1 ); //$NON-NLS-1$
-        String[] portHistory = HistoryUtils.load( ConnectionUIConstants.DIALOGSETTING_KEY_PORT_HISTORY
);
+        String[] portHistory = HistoryUtils.load( dialogSettings, ConnectionUIConstants.DIALOGSETTING_KEY_PORT_HISTORY
);
         portCombo = BaseWidgetUtils.createCombo( groupComposite, portHistory, -1, 2 );
         portCombo.setTextLimit( 5 );
         portCombo.setText( "389" ); //$NON-NLS-1$
@@ -422,8 +427,9 @@ public class NetworkParameterPage extend
      */
     public void saveDialogSettings()
     {
-        HistoryUtils.save( ConnectionUIConstants.DIALOGSETTING_KEY_HOST_HISTORY, hostCombo.getText()
);
-        HistoryUtils.save( ConnectionUIConstants.DIALOGSETTING_KEY_PORT_HISTORY, portCombo.getText()
);
+        IDialogSettings dialogSettings = ConnectionUIPlugin.getDefault().getDialogSettings();
+        HistoryUtils.save( dialogSettings, ConnectionUIConstants.DIALOGSETTING_KEY_HOST_HISTORY,
hostCombo.getText() );
+        HistoryUtils.save( dialogSettings, ConnectionUIConstants.DIALOGSETTING_KEY_PORT_HISTORY,
portCombo.getText() );
     }
 
 

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/BrowserCommonConstants.java
Fri Mar 23 14:29:56 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.studio.ldapbrowser.common;
 
+
 /**
  * 
  * Final reference -> class shouldn't be extended
@@ -37,15 +38,13 @@ public final class BrowserCommonConstant
     }
 
     /** The plug-in ID */
-    public static final String PLUGIN_ID = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Plugin_id" ); //$NON-NLS-1$
-
-    public static final int HISTORYSIZE = 20;
+    public static final String PLUGIN_ID = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Plugin_id" ); //$NON-NLS-1$
 
-    public static final String CONTEXT_WINDOWS = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Ctx_LdapBrowserWindows_id" ); //$NON-NLS-1$
-    public static final String CONTEXT_DIALOGS = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Ctx_LdapBrowserDialogs_id" ); //$NON-NLS-1$
+    public static final String CONTEXT_WINDOWS = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Ctx_LdapBrowserWindows_id" ); //$NON-NLS-1$
+    public static final String CONTEXT_DIALOGS = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Ctx_LdapBrowserDialogs_id" ); //$NON-NLS-1$
 
     public static final String ACTION_ID_EDIT_VALUE = BrowserCommonActivator.getDefault().getPluginProperties()
         .getString( "Cmd_EditValue_id" ); //$NON-NLS-1$
@@ -188,33 +187,33 @@ public final class BrowserCommonConstant
     public static final String IMG_DIT_STRUCTURE_RULE = "resources/icons/dit_structure_rule.png";
//$NON-NLS-1$
     public static final String IMG_NAME_FORM = "resources/icons/name_form.png"; //$NON-NLS-1$
 
-    public static final String CMD_ADD_ATTRIBUTE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_AddAttribute_id" ); //$NON-NLS-1$
-    public static final String CMD_ADD_VALUE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_AddValue_id" ); //$NON-NLS-1$
+    public static final String CMD_ADD_ATTRIBUTE = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_AddAttribute_id" ); //$NON-NLS-1$
+    public static final String CMD_ADD_VALUE = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_AddValue_id" ); //$NON-NLS-1$
     public static final String CMD_OPEN_SEARCH_RESULT = BrowserCommonActivator.getDefault().getPluginProperties()
         .getString( "Cmd_OpenSearchResult_id" ); //$NON-NLS-1$
-    public static final String CMD_COPY = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_Copy_id" ); //$NON-NLS-1$
-    public static final String CMD_PASTE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_Paste_id" ); //$NON-NLS-1$
-    public static final String CMD_DELETE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_Delete_id" ); //$NON-NLS-1$
-    public static final String CMD_PROPERTIES = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_Properties_id" ); //$NON-NLS-1$
-    public static final String CMD_FIND = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "Cmd_Find_id" ); //$NON-NLS-1$
-
-    public static final String PROP_VALUE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "PropPage_Value_id" ); //$NON-NLS-1$
-    public static final String PROP_ATTRIBUTE = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "PropPage_Attribute_id" ); //$NON-NLS-1$
-    public static final String PROP_SEARCH = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "PropPage_Search_id" ); //$NON-NLS-1$
-    public static final String PROP_BOOKMARK = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "PropPage_Bookmark_id" ); //$NON-NLS-1$
-    public static final String PROP_ENTRY = BrowserCommonActivator.getDefault().getPluginProperties().getString(
-        "PropPage_Entry_id" ); //$NON-NLS-1$
+    public static final String CMD_COPY = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_Copy_id" ); //$NON-NLS-1$
+    public static final String CMD_PASTE = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_Paste_id" ); //$NON-NLS-1$
+    public static final String CMD_DELETE = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_Delete_id" ); //$NON-NLS-1$
+    public static final String CMD_PROPERTIES = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_Properties_id" ); //$NON-NLS-1$
+    public static final String CMD_FIND = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "Cmd_Find_id" ); //$NON-NLS-1$
+
+    public static final String PROP_VALUE = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "PropPage_Value_id" ); //$NON-NLS-1$
+    public static final String PROP_ATTRIBUTE = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "PropPage_Attribute_id" ); //$NON-NLS-1$
+    public static final String PROP_SEARCH = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "PropPage_Search_id" ); //$NON-NLS-1$
+    public static final String PROP_BOOKMARK = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "PropPage_Bookmark_id" ); //$NON-NLS-1$
+    public static final String PROP_ENTRY = BrowserCommonActivator.getDefault().getPluginProperties()
+        .getString( "PropPage_Entry_id" ); //$NON-NLS-1$
 
     public static final String DND_ENTRY_TRANSFER = BrowserCommonActivator.getDefault().getPluginProperties()
         .getString( "DnD_EntryTransfer" ); //$NON-NLS-1$

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/FileBrowserWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/FileBrowserWidget.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/FileBrowserWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/FileBrowserWidget.java
Fri Mar 23 14:29:56 2012
@@ -23,6 +23,7 @@ package org.apache.directory.studio.ldap
 
 import java.io.File;
 
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
@@ -40,13 +41,12 @@ import org.eclipse.swt.widgets.FileDialo
 
 /**
  * The FileBrowserWidget provides a combo with a history of recently
- * used files an a browse button to open the file browser.
+ * used files and a browse button to open the file browser.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class FileBrowserWidget extends BrowserWidget
 {
-
     /** The Constant TYPE_OPEN is used to create a Open file dialog. */
     public static final int TYPE_OPEN = SWT.OPEN;
 
@@ -54,19 +54,19 @@ public class FileBrowserWidget extends B
     public static final int TYPE_SAVE = SWT.SAVE;
 
     /** The combo with the history of recently used files */
-    private Combo fileCombo;
+    protected Combo fileCombo;
 
     /** The button to launch the file browser */
-    private Button browseButton;
+    protected Button browseButton;
 
     /** The title */
-    private String title;
+    protected String title;
 
-    /** File extensions used within the lauched file browser */
-    private String[] extensions;
+    /** File extensions used within the launched file browser */
+    protected String[] extensions;
 
     /** The type */
-    private int type;
+    protected int type;
 
 
     /**
@@ -89,12 +89,12 @@ public class FileBrowserWidget extends B
      * 
      * @param parent the parent
      */
-    public void createWidget( final Composite parent )
+    public void createWidget( Composite parent )
     {
         // Combo
         fileCombo = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER );
         GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.widthHint = 250;
+        gd.widthHint = 50;
         fileCombo.setLayoutData( gd );
         fileCombo.setVisibleItemCount( 20 );
         fileCombo.addModifyListener( new ModifyListener()
@@ -111,7 +111,7 @@ public class FileBrowserWidget extends B
         {
             public void widgetSelected( SelectionEvent event )
             {
-                FileDialog fileDialog = new FileDialog( parent.getShell(), type );
+                FileDialog fileDialog = new FileDialog( browseButton.getShell(), type );
                 fileDialog.setText( title );
 
                 fileDialog.setFilterExtensions( extensions );
@@ -144,7 +144,8 @@ public class FileBrowserWidget extends B
         } );
 
         // file history
-        String[] history = HistoryUtils.load( BrowserCommonConstants.DIALOGSETTING_KEY_FILE_HISTORY
);
+        String[] history = HistoryUtils.load( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_FILE_HISTORY );
         fileCombo.setItems( history );
     }
 
@@ -176,7 +177,8 @@ public class FileBrowserWidget extends B
      */
     public void saveDialogSettings()
     {
-        HistoryUtils.save( BrowserCommonConstants.DIALOGSETTING_KEY_FILE_HISTORY, fileCombo.getText()
);
+        HistoryUtils.save( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_FILE_HISTORY, fileCombo.getText() );
     }
 
 

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/browser/BrowserQuickSearchWidget.java
Fri Mar 23 14:29:56 2012
@@ -26,12 +26,12 @@ import java.util.Collection;
 
 import org.apache.directory.shared.ldap.model.message.SearchScope;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.ui.widgets.ExtendedContentAssistCommandAdapter;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.actions.BrowserSelectionUtils;
-import org.apache.directory.studio.ldapbrowser.common.widgets.HistoryUtils;
 import org.apache.directory.studio.ldapbrowser.common.widgets.ListContentProposalProvider;
 import org.apache.directory.studio.ldapbrowser.core.jobs.SearchRunnable;
 import org.apache.directory.studio.ldapbrowser.core.jobs.StudioBrowserJob;
@@ -41,6 +41,7 @@ import org.apache.directory.studio.ldapb
 import org.apache.directory.studio.ldapbrowser.core.model.ISearch;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.QuickSearch;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
+import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.fieldassist.ComboContentAdapter;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -134,7 +135,8 @@ public class BrowserQuickSearchWidget
     {
         this.browserWidget = browserWidget;
 
-        if ( HistoryUtils.load( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY ).length == 0 )
+        if ( HistoryUtils.load( BrowserCommonActivator.getDefault().getDialogSettings(),
+            ATTRIBUTE_HISTORY_DIALOGSETTING_KEY ).length == 0 )
         {
             BrowserCommonActivator.getDefault().getDialogSettings().put( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY,
                 new String[]
@@ -183,13 +185,15 @@ public class BrowserQuickSearchWidget
     {
         this.browserWidget.getViewer().addPostSelectionChangedListener( selectionListener
);
 
+        IDialogSettings dialogSettings = BrowserCommonActivator.getDefault().getDialogSettings();
+
         // Reseting the layout of the composite to be displayed correctly
         GridData compositeGridData = new GridData( SWT.FILL, SWT.NONE, true, false );
         composite.setLayoutData( compositeGridData );
 
         innerComposite = BaseWidgetUtils.createColumnContainer( composite, 5, 1 );
 
-        String[] attributes = HistoryUtils.load( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY );
+        String[] attributes = HistoryUtils.load( dialogSettings, ATTRIBUTE_HISTORY_DIALOGSETTING_KEY
);
         quickSearchAttributeCombo = BaseWidgetUtils.createCombo( innerComposite, attributes,
-1, 1 );
         quickSearchAttributePP = new ListContentProposalProvider( attributes );
         new ExtendedContentAssistCommandAdapter( quickSearchAttributeCombo, new ComboContentAdapter(),
@@ -218,7 +222,7 @@ public class BrowserQuickSearchWidget
         GridData data = new GridData();
         quickSearchOperatorCombo.setLayoutData( data );
 
-        String[] values = HistoryUtils.load( VALUE_HISTORY_DIALOGSETTING_KEY );
+        String[] values = HistoryUtils.load( dialogSettings, VALUE_HISTORY_DIALOGSETTING_KEY
);
         quickSearchValueCombo = BaseWidgetUtils.createCombo( innerComposite, values, -1,
1 );
         quickSearchValuePP = new ListContentProposalProvider( values );
         new ExtendedContentAssistCommandAdapter( quickSearchValueCombo, new ComboContentAdapter(),
quickSearchValuePP,
@@ -280,12 +284,14 @@ public class BrowserQuickSearchWidget
             return;
         }
 
-        HistoryUtils.save( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY, quickSearchAttributeCombo.getText()
);
-        String[] attributes = HistoryUtils.load( ATTRIBUTE_HISTORY_DIALOGSETTING_KEY );
+        IDialogSettings dialogSettings = BrowserCommonActivator.getDefault().getDialogSettings();
+
+        HistoryUtils.save( dialogSettings, ATTRIBUTE_HISTORY_DIALOGSETTING_KEY, quickSearchAttributeCombo.getText()
);
+        String[] attributes = HistoryUtils.load( dialogSettings, ATTRIBUTE_HISTORY_DIALOGSETTING_KEY
);
         quickSearchAttributeCombo.setItems( attributes );
         quickSearchAttributeCombo.select( 0 );
-        HistoryUtils.save( VALUE_HISTORY_DIALOGSETTING_KEY, quickSearchValueCombo.getText()
);
-        String[] values = HistoryUtils.load( VALUE_HISTORY_DIALOGSETTING_KEY );
+        HistoryUtils.save( dialogSettings, VALUE_HISTORY_DIALOGSETTING_KEY, quickSearchValueCombo.getText()
);
+        String[] values = HistoryUtils.load( dialogSettings, VALUE_HISTORY_DIALOGSETTING_KEY
);
         quickSearchValueCombo.setItems( values );
         quickSearchValueCombo.select( 0 );
         quickSearchValuePP.setProposals( Arrays.asList( values ) );

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
Fri Mar 23 14:29:56 2012
@@ -23,6 +23,7 @@ package org.apache.directory.studio.ldap
 
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.core.DnUtils;
 import org.apache.directory.studio.connection.ui.RunnableContextRunner;
@@ -30,7 +31,6 @@ import org.apache.directory.studio.ldapb
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.dialogs.SelectEntryDialog;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
-import org.apache.directory.studio.ldapbrowser.common.widgets.HistoryUtils;
 import org.apache.directory.studio.ldapbrowser.core.jobs.ReadEntryRunnable;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
@@ -138,7 +138,8 @@ public class EntryWidget extends Browser
         dnCombo.setLayoutData( gd );
 
         // Dn history
-        String[] history = HistoryUtils.load( BrowserCommonConstants.DIALOGSETTING_KEY_DN_HISTORY
);
+        String[] history = HistoryUtils.load( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_DN_HISTORY );
         dnCombo.setItems( history );
         dnCombo.addModifyListener( new ModifyListener()
         {
@@ -170,7 +171,7 @@ public class EntryWidget extends Browser
                 if ( !Dn.isNullOrEmpty( dn ) )
                 {
                     dn = dn.getParent();
-                    
+
                     dnChanged();
                     internalSetEnabled();
                     notifyListeners();
@@ -201,13 +202,13 @@ public class EntryWidget extends Browser
 
                     // calculate initial Dn
                     Dn initialDn = dn;
-                    
+
                     if ( useLocalName && suffix != null && suffix.size()
> 0 )
                     {
                         if ( initialDn != null && initialDn.size() > 0 )
                         {
                             try
-                            {         
+                            {
                                 initialDn = initialDn.add( suffix );
                             }
                             catch ( LdapInvalidDnException lide )
@@ -221,10 +222,10 @@ public class EntryWidget extends Browser
                     IEntry entry = rootEntry;
                     if ( initialDn != null && initialDn.size() > 0 )
                     {
-                        entry = browserConnection.getEntryFromCache(initialDn);
+                        entry = browserConnection.getEntryFromCache( initialDn );
                         if ( entry == null )
                         {
-                            ReadEntryRunnable runnable = new ReadEntryRunnable( browserConnection,
initialDn);
+                            ReadEntryRunnable runnable = new ReadEntryRunnable( browserConnection,
initialDn );
                             RunnableContextRunner.execute( runnable, null, true );
                             entry = runnable.getReadEntry();
                         }
@@ -302,7 +303,8 @@ public class EntryWidget extends Browser
      */
     public void saveDialogSettings()
     {
-        HistoryUtils.save( BrowserCommonConstants.DIALOGSETTING_KEY_DN_HISTORY, this.dnCombo.getText()
);
+        HistoryUtils.save( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_DN_HISTORY, this.dnCombo.getText() );
     }
 
 

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/FilterWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/FilterWidget.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/FilterWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/FilterWidget.java
Fri Mar 23 14:29:56 2012
@@ -21,13 +21,14 @@
 package org.apache.directory.studio.ldapbrowser.common.widgets.search;
 
 
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.connection.ui.widgets.ExtendedContentAssistCommandAdapter;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.dialogs.FilterDialog;
 import org.apache.directory.studio.ldapbrowser.common.filtereditor.FilterContentAssistProcessor;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
-import org.apache.directory.studio.ldapbrowser.common.widgets.HistoryUtils;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.filter.parser.LdapFilterParser;
 import org.eclipse.jface.fieldassist.ComboContentAdapter;
@@ -169,7 +170,8 @@ public class FilterWidget extends Browse
         } );
 
         // filter history
-        String[] history = HistoryUtils.load( BrowserCommonConstants.DIALOGSETTING_KEY_SEARCH_FILTER_HISTORY
);
+        String[] history = HistoryUtils.load( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_SEARCH_FILTER_HISTORY );
         filterCombo.setItems( history );
 
         // initial values
@@ -237,7 +239,8 @@ public class FilterWidget extends Browse
      */
     public void saveDialogSettings()
     {
-        HistoryUtils.save( BrowserCommonConstants.DIALOGSETTING_KEY_SEARCH_FILTER_HISTORY,
filterCombo.getText() );
+        HistoryUtils.save( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_SEARCH_FILTER_HISTORY, filterCombo.getText()
);
     }
 
 

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java?rev=1304371&r1=1304370&r2=1304371&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/ReturningAttributesWidget.java
Fri Mar 23 14:29:56 2012
@@ -25,11 +25,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.directory.studio.common.ui.HistoryUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
+import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.widgets.BrowserWidget;
 import org.apache.directory.studio.ldapbrowser.common.widgets.DialogContentAssistant;
-import org.apache.directory.studio.ldapbrowser.common.widgets.HistoryUtils;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
@@ -113,7 +114,8 @@ public class ReturningAttributesWidget e
         raca.install( returningAttributesCombo );
 
         // History
-        String[] history = HistoryUtils.load( BrowserCommonConstants.DIALOGSETTING_KEY_RETURNING_ATTRIBUTES_HISTORY
);
+        String[] history = HistoryUtils.load( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_RETURNING_ATTRIBUTES_HISTORY );
         for ( int i = 0; i < history.length; i++ )
         {
             history[i] = Utils.arrayToString( stringToArray( history[i] ) );
@@ -204,8 +206,9 @@ public class ReturningAttributesWidget e
      */
     public void saveDialogSettings()
     {
-        HistoryUtils.save( BrowserCommonConstants.DIALOGSETTING_KEY_RETURNING_ATTRIBUTES_HISTORY,
Utils
-            .arrayToString( getReturningAttributes() ) );
+        HistoryUtils.save( BrowserCommonActivator.getDefault().getDialogSettings(),
+            BrowserCommonConstants.DIALOGSETTING_KEY_RETURNING_ATTRIBUTES_HISTORY,
+            Utils.arrayToString( getReturningAttributes() ) );
     }
 
 



Mime
View raw message