directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r608143 - in /directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor: ./ view/wizards/
Date Wed, 02 Jan 2008 16:49:09 GMT
Author: pamarcelot
Date: Wed Jan  2 08:49:08 2008
New Revision: 608143

URL: http://svn.apache.org/viewvc?rev=608143&view=rev
Log:
Fix for DIRSTUDIO-251 (Replace the Text Widget for the OID in the new AT and OC wizards by
a Drop-Down Combo with history of the last used OIDs).

Modified:
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java?rev=608143&r1=608142&r2=608143&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginConstants.java
Wed Jan  2 08:49:08 2008
@@ -372,4 +372,7 @@
         + ".fileDialog.importSchemasOpenLDAP";
     /** The File Dialog path for 'Import Schemas from XML files' */
     public static final String FILE_DIALOG_IMPORT_SCHEMAS_XML = Activator.PLUGIN_ID + ".fileDialog.importSchemasXML";
+
+    // Dialog Settings
+    public static final String DIALOG_SETTINGS_OID_HISTORY = Activator.PLUGIN_ID + ".dialogSettings.oidHistory";
 }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java?rev=608143&r1=608142&r2=608143&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/PluginUtils.java
Wed Jan  2 08:49:08 2008
@@ -28,6 +28,7 @@
 import java.net.URL;
 import java.text.MessageFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
@@ -321,7 +322,7 @@
             PluginUtils.logError( loggerMessage, e );
         }
 
-        if ( dialogMessage != null ) 
+        if ( dialogMessage != null )
         {
             ViewUtils.displayErrorMessageBox( ( ( dialogTitle == null ) ? "" : dialogTitle
), dialogMessage );
         }
@@ -411,5 +412,55 @@
         }
 
         return schemaConnectors;
+    }
+
+
+    /**
+     * Saves the the given value under the given key in the dialog settings.
+     *
+     * @param key
+     *      the key
+     * @param value
+     *      the value
+     */
+    public static void saveDialogSettingsHistory( String key, String value )
+    {
+        // get current history
+        String[] history = loadDialogSettingsHistory( 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()] );
+        Activator.getDefault().getDialogSettings().put( key, history );
+    }
+
+
+    /**
+     * Loads the value of the given key from the dialog settings.
+     *
+     * @param key the key
+     * @return the value
+     */
+    public static String[] loadDialogSettingsHistory( String key )
+    {
+        String[] history = Activator.getDefault().getDialogSettings().getArray( key );
+        if ( history == null )
+        {
+            history = new String[0];
+        }
+        return history;
     }
 }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java?rev=608143&r1=608142&r2=608143&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeGeneralWizardPage.java
Wed Jan  2 08:49:08 2008
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.view.dialogs.EditAliasesDialog;
@@ -80,7 +81,7 @@
 
     // UI fields
     private ComboViewer schemaComboViewer;
-    private Text oidText;
+    private Combo oidCombo;
     private Text aliasesText;
     private Button aliasesButton;
     private Text descriptionText;
@@ -160,9 +161,9 @@
         // OID
         Label oidLabel = new Label( namingDescriptionGroup, SWT.NONE );
         oidLabel.setText( "OID:" );
-        oidText = new Text( namingDescriptionGroup, SWT.BORDER );
-        oidText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
-        oidText.addModifyListener( new ModifyListener()
+        oidCombo = new Combo( namingDescriptionGroup, SWT.DROP_DOWN | SWT.BORDER );
+        oidCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+        oidCombo.addModifyListener( new ModifyListener()
         {
             /* (non-Javadoc)
              * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
@@ -172,7 +173,7 @@
                 dialogChanged();
             }
         } );
-        oidText.addVerifyListener( new VerifyListener()
+        oidCombo.addVerifyListener( new VerifyListener()
         {
             /* (non-Javadoc)
              * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
@@ -185,6 +186,7 @@
                 }
             }
         } );
+        oidCombo.setItems( PluginUtils.loadDialogSettingsHistory( PluginConstants.DIALOG_SETTINGS_OID_HISTORY
) );
 
         // Aliases
         Label aliasesLabel = new Label( namingDescriptionGroup, SWT.NONE );
@@ -278,18 +280,18 @@
             displayErrorMessage( "A Schema must be specified." );
             return;
         }
-        else if ( oidText.getText().equals( "" ) )
+        else if ( oidCombo.getText().equals( "" ) )
         {
             displayErrorMessage( "An OID must be specified." );
             return;
         }
-        else if ( ( !oidText.getText().equals( "" ) ) && ( !OID.isOID( oidText.getText()
) ) )
+        else if ( ( !oidCombo.getText().equals( "" ) ) && ( !OID.isOID( oidCombo.getText()
) ) )
         {
             displayErrorMessage( "Incorrect OID." );
             return;
         }
-        else if ( ( !oidText.getText().equals( "" ) ) && ( OID.isOID( oidText.getText()
) )
-            && ( schemaHandler.isAliasOrOidAlreadyTaken( oidText.getText() ) ) )
+        else if ( ( !oidCombo.getText().equals( "" ) ) && ( OID.isOID( oidCombo.getText()
) )
+            && ( schemaHandler.isAliasOrOidAlreadyTaken( oidCombo.getText() ) ) )
         {
             displayErrorMessage( "An object with this OID already exists." );
             return;
@@ -383,7 +385,7 @@
      */
     public String getOidValue()
     {
-        return oidText.getText();
+        return oidCombo.getText();
     }
 
 

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java?rev=608143&r1=608142&r2=608143&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeWizard.java
Wed Jan  2 08:49:08 2008
@@ -21,6 +21,8 @@
 
 
 import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.model.AttributeTypeImpl;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -71,6 +73,7 @@
      */
     public boolean performFinish()
     {
+        // Creating the new attribute type
         AttributeTypeImpl newAT = new AttributeTypeImpl( generalPage.getOidValue() );
         newAT.setSchema( generalPage.getSchemaValue() );
         newAT.setNames( generalPage.getAliasesValue() );
@@ -87,7 +90,11 @@
         newAT.setOrderingName( matchingRulesPage.getOrderingMatchingRuleValue() );
         newAT.setSubstrName( matchingRulesPage.getSubstringMatchingRuleValue() );
 
+        // Adding the new attribute type
         Activator.getDefault().getSchemaHandler().addAttributeType( newAT );
+
+        // Saving the Dialog Settings OID History
+        PluginUtils.saveDialogSettingsHistory( PluginConstants.DIALOG_SETTINGS_OID_HISTORY,
newAT.getOid() );
 
         return true;
     }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java?rev=608143&r1=608142&r2=608143&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassGeneralPageWizardPage.java
Wed Jan  2 08:49:08 2008
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.studio.schemaeditor.Activator;
 import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.apache.directory.studio.schemaeditor.view.dialogs.EditAliasesDialog;
@@ -80,7 +81,7 @@
 
     // UI fields
     private ComboViewer schemaComboViewer;
-    private Text oidText;
+    private Combo oidCombo;
     private Text aliasesText;
     private Button aliasesButton;
     private Text descriptionText;
@@ -160,9 +161,9 @@
         // OID
         Label oidLabel = new Label( namingDescriptionGroup, SWT.NONE );
         oidLabel.setText( "OID:" );
-        oidText = new Text( namingDescriptionGroup, SWT.BORDER );
-        oidText.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
-        oidText.addModifyListener( new ModifyListener()
+        oidCombo = new Combo( namingDescriptionGroup, SWT.DROP_DOWN | SWT.BORDER );
+        oidCombo.setLayoutData( new GridData( SWT.FILL, SWT.NONE, true, false, 2, 1 ) );
+        oidCombo.addModifyListener( new ModifyListener()
         {
             /* (non-Javadoc)
              * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
@@ -172,7 +173,7 @@
                 dialogChanged();
             }
         } );
-        oidText.addVerifyListener( new VerifyListener()
+        oidCombo.addVerifyListener( new VerifyListener()
         {
             /* (non-Javadoc)
              * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
@@ -185,6 +186,7 @@
                 }
             }
         } );
+        oidCombo.setItems( PluginUtils.loadDialogSettingsHistory( PluginConstants.DIALOG_SETTINGS_OID_HISTORY
) );
 
         // Aliases
         Label aliasesLabel = new Label( namingDescriptionGroup, SWT.NONE );
@@ -278,18 +280,18 @@
             displayErrorMessage( "A Schema must be specified." );
             return;
         }
-        else if ( oidText.getText().equals( "" ) )
+        else if ( oidCombo.getText().equals( "" ) )
         {
             displayErrorMessage( "An OID must be specified." );
             return;
         }
-        else if ( ( !oidText.getText().equals( "" ) ) && ( !OID.isOID( oidText.getText()
) ) )
+        else if ( ( !oidCombo.getText().equals( "" ) ) && ( !OID.isOID( oidCombo.getText()
) ) )
         {
             displayErrorMessage( "Incorrect OID." );
             return;
         }
-        else if ( ( !oidText.getText().equals( "" ) ) && ( OID.isOID( oidText.getText()
) )
-            && ( schemaHandler.isAliasOrOidAlreadyTaken( oidText.getText() ) ) )
+        else if ( ( !oidCombo.getText().equals( "" ) ) && ( OID.isOID( oidCombo.getText()
) )
+            && ( schemaHandler.isAliasOrOidAlreadyTaken( oidCombo.getText() ) ) )
         {
             displayErrorMessage( "An object with this OID already exists." );
             return;
@@ -383,7 +385,7 @@
      */
     public String getOidValue()
     {
-        return oidText.getText();
+        return oidCombo.getText();
     }
 
 

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java?rev=608143&r1=608142&r2=608143&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewObjectClassWizard.java
Wed Jan  2 08:49:08 2008
@@ -21,6 +21,8 @@
 
 
 import org.apache.directory.studio.schemaeditor.Activator;
+import org.apache.directory.studio.schemaeditor.PluginConstants;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
 import org.apache.directory.studio.schemaeditor.model.ObjectClassImpl;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -74,6 +76,7 @@
      */
     public boolean performFinish()
     {
+        // Creating the new object class
         ObjectClassImpl newOC = new ObjectClassImpl( generalPage.getOidValue() );
         newOC.setSchema( generalPage.getSchemaValue() );
         newOC.setNames( generalPage.getAliasesValue() );
@@ -84,7 +87,11 @@
         newOC.setMustNamesList( mandatoryAttributesPage.getMandatoryAttributeTypesNames()
);
         newOC.setMayNamesList( optionalAttributesPage.getOptionalAttributeTypesNames() );
 
+        // Adding the new object class
         Activator.getDefault().getSchemaHandler().addObjectClass( newOC );
+
+        // Saving the Dialog Settings OID History
+        PluginUtils.saveDialogSettingsHistory( PluginConstants.DIALOG_SETTINGS_OID_HISTORY,
newOC.getOid() );
 
         return true;
     }



Mime
View raw message