directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r520897 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main: java/org/apache/directory/ldapstudio/schemas/model/ java/org/apache/directory/ldapstudio/schemas/view/ java/org/apache/directory/ldapstudio/schemas/view/editors/ j...
Date Wed, 21 Mar 2007 14:19:47 GMT
Author: pamarcelot
Date: Wed Mar 21 07:19:46 2007
New Revision: 520897

URL: http://svn.apache.org/viewvc?view=rev&rev=520897
Log:
Improved handling of OIDs in Wizards and Editors.
Added Javadoc to Wizards classes.

Removed:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/model/OID.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizard.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizard.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizard.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizardPage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/wizards/messages.properties

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
Wed Mar 21 07:19:46 2007
@@ -20,6 +20,11 @@
 package org.apache.directory.ldapstudio.schemas.view;
 
 
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.PlatformUI;
+
+
 /**
  * This Helper Class contains useful methods used to create the UI.
  *
@@ -28,6 +33,15 @@
  */
 public class ViewUtils
 {
+    /** The Black Color */
+    public static final Color COLOR_BLACK = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()
+        .getDisplay().getSystemColor( SWT.COLOR_BLACK );
+
+    /** The Red Color */
+    public static final Color COLOR_RED = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay()
+        .getSystemColor( SWT.COLOR_RED );
+
+
     /**
      * Concatenates all aliases in a String format. Aliases are separated with a comma (',')
      *

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/AttributeTypeFormEditorOverviewPage.java
Wed Mar 21 07:19:46 2007
@@ -35,6 +35,7 @@
 import org.apache.directory.ldapstudio.schemas.model.Syntax;
 import org.apache.directory.ldapstudio.schemas.model.Syntaxes;
 import org.apache.directory.ldapstudio.schemas.view.ViewUtils;
+import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.window.Window;
@@ -77,6 +78,9 @@
     /** The page title */
     public static String TITLE = Messages.getString( "AttributeTypeFormEditor.Overview" );
 
+    /** The original object class */
+    private AttributeType originalAttributeType;
+
     /** The modified object class */
     private AttributeType modifiedAttributeType;
 
@@ -128,13 +132,47 @@
         }
     };
 
-    /** The listener for the OID Text Widget */
-    private ModifyListener oidTextListener = new ModifyListener()
+    /** The Modify listener for the OID Text Widget */
+    private ModifyListener oidTextModifyListener = new ModifyListener()
     {
         public void modifyText( ModifyEvent e )
         {
-            modifiedAttributeType.setOid( oidText.getText() );
-            setEditorDirty();
+            oidText.setForeground( ViewUtils.COLOR_BLACK );
+            oidText.setToolTipText( "" );
+
+            String oid = oidText.getText();
+
+            if ( OID.isOID( oid ) )
+            {
+                if ( ( originalAttributeType.getOid().equals( oid ) )
+                    || !( SchemaPool.getInstance().containsSchemaElement( oid ) ) )
+                {
+                    modifiedAttributeType.setOid( oid );
+                    setEditorDirty();
+                }
+                else
+                {
+                    oidText.setForeground( ViewUtils.COLOR_RED );
+                    oidText.setToolTipText( "An element with same oid already exists." );
+                }
+            }
+            else
+            {
+                oidText.setForeground( ViewUtils.COLOR_RED );
+                oidText.setToolTipText( "Malformed OID." );
+            }
+        }
+    };
+
+    /** The Verify listener for the OID Text Widget */
+    private VerifyListener oidTextVerifyListener = new VerifyListener()
+    {
+        public void verifyText( VerifyEvent e )
+        {
+            if ( !e.text.matches( "([0-9]*\\.?)*" ) )
+            {
+                e.doit = false;
+            }
         }
     };
 
@@ -381,8 +419,9 @@
      */
     protected void createFormContent( IManagedForm managedForm )
     {
-        // Getting the modified attribute type and listening to its modifications
+        // Getting the original and modified attribute types
         modifiedAttributeType = ( ( AttributeTypeFormEditor ) getEditor() ).getModifiedAttributeType();
+        originalAttributeType = ( ( AttributeTypeFormEditor ) getEditor() ).getOriginalAttributeType();
 
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
@@ -444,22 +483,12 @@
         aliasesButton = toolkit.createButton( client_general_information, Messages
             .getString( "AttributeTypeFormEditorOverviewPage.Manage_Aliases" ), SWT.PUSH
); //$NON-NLS-1$
         aliasesButton.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false, 2, 1
) );
-        
+
         // OID Field
         toolkit
             .createLabel( client_general_information, Messages.getString( "AttributeTypeFormEditorOverviewPage.OID"
) ); //$NON-NLS-1$
         oidText = toolkit.createText( client_general_information, "" ); //$NON-NLS-1$
         oidText.setLayoutData( new GridData( SWT.FILL, 0, true, false, 2, 1 ) );
-        oidText.addVerifyListener( new VerifyListener()
-        {
-            public void verifyText( VerifyEvent e )
-            {
-                if ( e.text.length() < 20 && !e.text.matches( "([0-9]+\\.?)*"
) )
-                {
-                    e.doit = false;
-                }
-            }
-        } );
 
         // DESCRIPTION Field
         toolkit.createLabel( client_general_information, Messages
@@ -927,7 +956,8 @@
     {
         if ( modifiedAttributeType.getOriginatingSchema().type == Schema.SchemaType.userSchema
)
         {
-            oidText.addModifyListener( oidTextListener );
+            oidText.addModifyListener( oidTextModifyListener );
+            oidText.addVerifyListener( oidTextVerifyListener );
             descriptionText.addModifyListener( descriptionTextListener );
             supLabel.addHyperlinkListener( supLabelListener );
             supCombo.addModifyListener( supComboListener );
@@ -956,7 +986,8 @@
      */
     private void removeListeners()
     {
-        oidText.removeModifyListener( oidTextListener );
+        oidText.removeModifyListener( oidTextModifyListener );
+        oidText.removeVerifyListener( oidTextVerifyListener );
         aliasesButton.removeSelectionListener( aliasesButtonListener );
         schemaLink.removeHyperlinkListener( schemaLinkListener );
         descriptionText.removeModifyListener( descriptionTextListener );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ObjectClassFormEditorOverviewPage.java
Wed Mar 21 07:19:46 2007
@@ -34,6 +34,7 @@
 import org.apache.directory.ldapstudio.schemas.model.Schema;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.apache.directory.ldapstudio.schemas.view.ViewUtils;
+import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -82,6 +83,9 @@
     /** The page title*/
     public static final String TITLE = Messages.getString( "ObjectClassFormEditor.Overview"
);
 
+    /** The original object class */
+    private ObjectClass originalObjectClass;
+
     /** The modified object class */
     private ObjectClass modifiedObjectClass;
 
@@ -131,13 +135,47 @@
         }
     };
 
-    /** The listener for OID Text Widget */
-    private ModifyListener oidTextListener = new ModifyListener()
+    /** The Modify listener for the OID Text Widget */
+    private ModifyListener oidTextModifyListener = new ModifyListener()
     {
         public void modifyText( ModifyEvent e )
         {
-            modifiedObjectClass.setOid( oidText.getText() );
-            setEditorDirty();
+            oidText.setForeground( ViewUtils.COLOR_BLACK );
+            oidText.setToolTipText( "" );
+
+            String oid = oidText.getText();
+
+            if ( OID.isOID( oid ) )
+            {
+                if ( ( originalObjectClass.getOid().equals( oid ) )
+                    || !( SchemaPool.getInstance().containsSchemaElement( oid ) ) )
+                {
+                    modifiedObjectClass.setOid( oid );
+                    setEditorDirty();
+                }
+                else
+                {
+                    oidText.setForeground( ViewUtils.COLOR_RED );
+                    oidText.setToolTipText( "An element with same oid already exists." );
+                }
+            }
+            else
+            {
+                oidText.setForeground( ViewUtils.COLOR_RED );
+                oidText.setToolTipText( "Malformed OID." );
+            }
+        }
+    };
+
+    /** The Verify listener for the OID Text Widget */
+    private VerifyListener oidTextVerifyListener = new VerifyListener()
+    {
+        public void verifyText( VerifyEvent e )
+        {
+            if ( !e.text.matches( "([0-9]*\\.?)*" ) )
+            {
+                e.doit = false;
+            }
         }
     };
 
@@ -475,8 +513,9 @@
      */
     protected void createFormContent( IManagedForm managedForm )
     {
-        // Getting the modified object class
+        // Getting the original and modified object classes
         modifiedObjectClass = ( ( ObjectClassFormEditor ) getEditor() ).getModifiedObjectClass();
+        originalObjectClass = ( ( ObjectClassFormEditor ) getEditor() ).getOriginalObjectClass();
 
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
@@ -917,7 +956,8 @@
     {
         if ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.userSchema
)
         {
-            oidText.addModifyListener( oidTextListener );
+            oidText.addModifyListener( oidTextModifyListener );
+            oidText.addVerifyListener( oidTextVerifyListener );
             descriptionText.addModifyListener( descriptionTextListener );
             supCombo.addModifyListener( supComboListener );
             classTypeCombo.addModifyListener( classTypeListener );
@@ -948,7 +988,8 @@
     private void removeListeners()
     {
         aliasesButton.removeSelectionListener( aliasesButtonListener );
-        oidText.removeModifyListener( oidTextListener );
+        oidText.removeModifyListener( oidTextModifyListener );
+        oidText.removeVerifyListener( oidTextVerifyListener );
         schemaLink.removeHyperlinkListener( schemaLinkListener );
         descriptionText.removeModifyListener( descriptionTextListener );
         supLabel.removeHyperlinkListener( supLabelListener );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizard.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizard.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizard.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizard.java
Wed Mar 21 07:19:46 2007
@@ -27,7 +27,6 @@
 import org.apache.directory.ldapstudio.schemas.view.editors.AttributeTypeFormEditor;
 import org.apache.directory.ldapstudio.schemas.view.editors.AttributeTypeFormEditorInput;
 import org.apache.directory.server.core.tools.schema.AttributeTypeLiteral;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
@@ -41,16 +40,15 @@
  */
 public class CreateANewAttributeTypeWizard extends Wizard implements INewWizard
 {
-
-    private ISelection selection;
-
+    /** The default page */
     private CreateANewAttributeTypeWizardPage page;
 
+    /** The schema name */
     private String schemaName;
 
 
     /**
-     * Default Constructor
+     * Creates a new instance of CreateANewAttributeTypeWizard.
      * 
      * @param schemaName
      *            the schema name in which should be added the new attribute
@@ -63,12 +61,9 @@
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()
      */
-    @Override
     public boolean performFinish()
     {
         // Getting the SchemaPool
@@ -79,10 +74,11 @@
 
         // Creating the new attribute type and adding it to the schema
         AttributeTypeLiteral attributeTypeLiteral = new AttributeTypeLiteral( this.page.getOidField()
);
-        attributeTypeLiteral.setNames( new String[] { this.page.getNameField() } );
+        attributeTypeLiteral.setNames( new String[]
+            { this.page.getNameField() } );
         AttributeType attributeType = new AttributeType( attributeTypeLiteral, schema );
         schema.addAttributeType( attributeType );
-        
+
         // Opening the associated editor
         AttributeTypeFormEditorInput input = new AttributeTypeFormEditorInput( attributeType
);
         String editorId = AttributeTypeFormEditor.ID;
@@ -92,32 +88,27 @@
         }
         catch ( PartInitException e )
         {
+            // TODO Log exception.
         }
 
         return true;
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
-     *      org.eclipse.jface.viewers.IStructuredSelection)
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
      */
-    public void init( IWorkbench workbench, IStructuredSelection selection )
+    public void addPages()
     {
-        this.selection = selection;
+        this.page = new CreateANewAttributeTypeWizardPage();
+        addPage( page );
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.wizard.Wizard#addPages()
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
      */
-    public void addPages()
+    public void init( IWorkbench workbench, IStructuredSelection selection )
     {
-        this.page = new CreateANewAttributeTypeWizardPage( selection );
-        addPage( page );
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizardPage.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewAttributeTypeWizardPage.java
Wed Mar 21 07:19:46 2007
@@ -21,17 +21,13 @@
 package org.apache.directory.ldapstudio.schemas.view.wizards;
 
 
-import java.util.Map;
-
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
-import org.apache.directory.ldapstudio.schemas.model.OID;
-import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.apache.directory.ldapstudio.schemas.view.preferences.OidPreferencePage;
+import org.apache.directory.shared.asn1.primitives.OID;
 import org.eclipse.core.runtime.preferences.ConfigurationScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -54,31 +50,21 @@
  */
 public class CreateANewAttributeTypeWizardPage extends WizardPage
 {
-
-    @SuppressWarnings("unused")//$NON-NLS-1$
-    private ISelection selection;
-
-    private Map<String, SchemaElement> elements;
-
+    // UI Fields
     private Text oidField;
-
     private Text nameField;
 
 
     /**
-     * Default constructor
-     * 
-     * @param selection
+     * Creates a new instance of CreateANewAttributeTypeWizardPage.
      */
-    public CreateANewAttributeTypeWizardPage( ISelection selection )
+    public CreateANewAttributeTypeWizardPage()
     {
         super( "CreateANewAttributeTypeWizardPage" ); //$NON-NLS-1$
         setTitle( Messages.getString( "CreateANewAttributeTypeWizardPage.Page_Title" ) );
//$NON-NLS-1$
         setDescription( Messages.getString( "CreateANewAttributeTypeWizardPage.Page_Description"
) ); //$NON-NLS-1$
-        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID,
PluginConstants.IMG_ATTRIBUTE_TYPE_NEW_WIZARD ) );
-        this.selection = selection;
-        
-        elements = SchemaPool.getInstance().getSchemaElements();
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_ATTRIBUTE_TYPE_NEW_WIZARD ) );
     }
 
 
@@ -168,7 +154,7 @@
         {
             public void verifyText( VerifyEvent e )
             {
-                if ( e.text.length() < 20  && !e.text.matches( "([0-9]+\\.?)*"
) )
+                if ( !e.text.matches( "([0-9]*\\.?)*" ) )
                 {
                     e.doit = false;
                 }
@@ -194,6 +180,9 @@
     }
 
 
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
     private void dialogChanged()
     {
         if ( getOidField().length() == 0 )
@@ -202,7 +191,7 @@
             return;
         }
 
-        if ( !OID.validate( getOidField() ) )
+        if ( !OID.isOID( getOidField() ) )
         {
             updateStatus( Messages.getString( "CreateANewAttributeTypeWizardPage.Malformed_OID"
) ); //$NON-NLS-1$
             return;
@@ -214,14 +203,14 @@
             return;
         }
 
-        if ( elements.containsKey( getOidField() ) )
+        if ( SchemaPool.getInstance().containsSchemaElement( getOidField() ) )
         {
             updateStatus( Messages
                 .getString( "CreateANewAttributeTypeWizardPage.An_element_of_the_same_OID_already_exists"
) ); //$NON-NLS-1$
             return;
         }
 
-        if ( elements.containsKey( getNameField() ) )
+        if ( SchemaPool.getInstance().containsSchemaElement( getNameField() ) )
         {
             updateStatus( Messages
                 .getString( "CreateANewAttributeTypeWizardPage.An_element_of_the_same_name_already_exists"
) ); //$NON-NLS-1$
@@ -232,6 +221,12 @@
     }
 
 
+    /**
+     * Updates the status of the page.
+     *
+     * @param message
+     *      the message to display
+     */
     private void updateStatus( String message )
     {
         setErrorMessage( message );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizard.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizard.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizard.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizard.java
Wed Mar 21 07:19:46 2007
@@ -27,7 +27,6 @@
 import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditor;
 import org.apache.directory.ldapstudio.schemas.view.editors.ObjectClassFormEditorInput;
 import org.apache.directory.server.core.tools.schema.ObjectClassLiteral;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
@@ -38,20 +37,21 @@
 
 /**
  * Wizard for creation of a new object class
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class CreateANewObjectClassWizard extends Wizard implements INewWizard
 {
-
-    private ISelection selection;
-
+    /** The Default Page */
     private CreateANewObjectClassWizardPage page;
 
+    /** The schema name*/
     private String schemaName;
 
 
     /**
-     * Default constructor
-     * 
+     * Creates a new instance of CreateANewObjectClassWizard.
      * @param schemaName
      *            the schema name in which should be added the new object class
      */
@@ -62,12 +62,9 @@
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()
      */
-    @Override
     public boolean performFinish()
     {
         // Getting the SchemaPool
@@ -78,8 +75,10 @@
 
         // Creating the new object class and adding it to the schema
         ObjectClassLiteral objectClassLiteral = new ObjectClassLiteral( this.page.getOidField()
);
-        objectClassLiteral.setNames( new String[] { this.page.getNameField() } );
-        objectClassLiteral.setSuperiors( new String[]{ "top" } ); //$NON-NLS-1$
+        objectClassLiteral.setNames( new String[]
+            { this.page.getNameField() } );
+        objectClassLiteral.setSuperiors( new String[]
+            { "top" } ); //$NON-NLS-1$
         ObjectClass objectClass = new ObjectClass( objectClassLiteral, schema );
         schema.addObjectClass( objectClass );
 
@@ -93,31 +92,25 @@
         catch ( PartInitException e )
         {
         }
-        
+
         return true;
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
-     *      org.eclipse.jface.viewers.IStructuredSelection)
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
      */
-    public void init( IWorkbench workbench, IStructuredSelection selection )
+    public void addPages()
     {
-        this.selection = selection;
+        this.page = new CreateANewObjectClassWizardPage();
+        addPage( page );
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.wizard.Wizard#addPages()
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
      */
-    public void addPages()
+    public void init( IWorkbench workbench, IStructuredSelection selection )
     {
-        this.page = new CreateANewObjectClassWizardPage( selection );
-        addPage( page );
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizardPage.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewObjectClassWizardPage.java
Wed Mar 21 07:19:46 2007
@@ -21,17 +21,13 @@
 package org.apache.directory.ldapstudio.schemas.view.wizards;
 
 
-import java.util.Map;
-
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
-import org.apache.directory.ldapstudio.schemas.model.OID;
-import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.apache.directory.ldapstudio.schemas.view.preferences.OidPreferencePage;
+import org.apache.directory.shared.asn1.primitives.OID;
 import org.eclipse.core.runtime.preferences.ConfigurationScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -51,33 +47,27 @@
 
 /**
  * Default Page for new attribute type wizard
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class CreateANewObjectClassWizardPage extends WizardPage
 {
-
-    @SuppressWarnings("unused")//$NON-NLS-1$
-    private ISelection selection;
-    private Map<String, SchemaElement> elements;
-
+    // UI Fields
     private Text oidField;
-
     private Text nameField;
 
 
     /**
-     * Default constructor
-     * 
-     * @param selection
+     * Creates a new instance of CreateANewObjectClassWizardPage.
      */
-    public CreateANewObjectClassWizardPage( ISelection selection )
+    public CreateANewObjectClassWizardPage()
     {
         super( "CreateANewObjecClassWizardPage" ); //$NON-NLS-1$
         setTitle( Messages.getString( "CreateANewObjectClassWizardPage.Page_Title" ) ); //$NON-NLS-1$
         setDescription( Messages.getString( "CreateANewObjectClassWizardPage.Page_Description"
) ); //$NON-NLS-1$
-        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_OBJECT_CLASS_NEW_WIZARD ) );
-        this.selection = selection;
-
-        elements = SchemaPool.getInstance().getSchemaElements();
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_OBJECT_CLASS_NEW_WIZARD ) );
     }
 
 
@@ -103,9 +93,7 @@
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
      */
     public void createControl( Composite parent )
@@ -168,7 +156,7 @@
         {
             public void verifyText( VerifyEvent e )
             {
-                if ( e.text.length() < 20  && !e.text.matches( "([0-9]+\\.?)*"
) )
+                if ( !e.text.matches( "([0-9]*\\.?)*" ) )
                 {
                     e.doit = false;
                 }
@@ -194,6 +182,9 @@
     }
 
 
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
     private void dialogChanged()
     {
         if ( getOidField().length() == 0 )
@@ -202,7 +193,7 @@
             return;
         }
 
-        if ( !OID.validate( getOidField() ) )
+        if ( !OID.isOID( getOidField() ) )
         {
             updateStatus( Messages.getString( "CreateANewObjectClassWizardPage.Malforme_OID"
) ); //$NON-NLS-1$
             return;
@@ -214,17 +205,17 @@
             return;
         }
 
-        if ( elements.containsKey( getOidField() ) )
+        if ( SchemaPool.getInstance().containsSchemaElement( getOidField() ) )
         {
             updateStatus( Messages
                 .getString( "CreateANewObjectClassWizardPage.An_element_of_the_same_OID_already_exists"
) ); //$NON-NLS-1$
             return;
         }
 
-        if ( elements.containsKey( getNameField() ) )
+        if ( SchemaPool.getInstance().containsSchemaElement( getNameField() ) )
         {
             updateStatus( Messages
-                .getString( "CreateANewObjectClassWizardPage.An_object_class_of_the_same_name_already_exists"
) ); //$NON-NLS-1$
+                .getString( "CreateANewObjectClassWizardPage.An_element_of_the_same_name_already_exists"
) ); //$NON-NLS-1$
             return;
         }
 
@@ -232,6 +223,12 @@
     }
 
 
+    /**
+     * Updates the status of the page.
+     *
+     * @param message
+     *      the message to display
+     */
     private void updateStatus( String message )
     {
         setErrorMessage( message );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizard.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizard.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizard.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizard.java
Wed Mar 21 07:19:46 2007
@@ -23,7 +23,6 @@
 
 import org.apache.directory.ldapstudio.schemas.model.Schema;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.INewWizard;
@@ -31,30 +30,20 @@
 
 
 /**
- * Wizard for creation of a new schema
+ * Wizard for creation of a new schema.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
  */
 public class CreateANewSchemaWizard extends Wizard implements INewWizard
 {
-    private ISelection selection;
-
+    /** The default page */
     private CreateANewSchemaWizardPage page;
 
 
-    /**
-     * Default constructor
-     */
-    public CreateANewSchemaWizard()
-    {
-        super();
-    }
-
-
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()
      */
-    @Override
     public boolean performFinish()
     {
         SchemaPool pool = SchemaPool.getInstance();
@@ -63,26 +52,20 @@
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
-     *      org.eclipse.jface.viewers.IStructuredSelection)
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.wizard.Wizard#addPages()
      */
-    public void init( IWorkbench workbench, IStructuredSelection selection )
+    public void addPages()
     {
-        this.selection = selection;
+        this.page = new CreateANewSchemaWizardPage();
+        addPage( page );
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.wizard.Wizard#addPages()
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
      */
-    public void addPages()
+    public void init( IWorkbench workbench, IStructuredSelection selection )
     {
-        this.page = new CreateANewSchemaWizardPage( selection );
-        addPage( page );
     }
 }

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizardPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizardPage.java?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizardPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/wizards/CreateANewSchemaWizardPage.java
Wed Mar 21 07:19:46 2007
@@ -24,7 +24,6 @@
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
-import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -42,25 +41,20 @@
  */
 public class CreateANewSchemaWizardPage extends WizardPage
 {
-
-    @SuppressWarnings("unused")//$NON-NLS-1$
-    private ISelection selection;
-
+    // UI Fields
     private Text nameField;
 
 
     /**
-     * Default constructor
-     * 
-     * @param selection
+     * Creates a new instance of CreateANewSchemaWizardPage.
      */
-    public CreateANewSchemaWizardPage( ISelection selection )
+    public CreateANewSchemaWizardPage()
     {
         super( "CreateANewSchemaWizardPage" ); //$NON-NLS-1$
         setTitle( Messages.getString( "CreateANewSchemaWizardPage.Page_Title" ) ); //$NON-NLS-1$
         setDescription( Messages.getString( "CreateANewSchemaWizardPage.Page_Description"
) ); //$NON-NLS-1$
-        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
PluginConstants.IMG_SCHEMA_NEW_WIZARD ) );
-        this.selection = selection;
+        setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+            PluginConstants.IMG_SCHEMA_NEW_WIZARD ) );
     }
 
 
@@ -75,9 +69,7 @@
     }
 
 
-    /*
-     * (non-Javadoc)
-     * 
+    /* (non-Javadoc)
      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
      */
     public void createControl( Composite parent )
@@ -106,6 +98,9 @@
     }
 
 
+    /**
+     * This method is called when the user modifies something in the UI.
+     */
     private void dialogChanged()
     {
         if ( getNameField().length() == 0 )
@@ -125,6 +120,12 @@
     }
 
 
+    /**
+     * Updates the status of the page.
+     *
+     * @param message
+     *      the message to display
+     */
     private void updateStatus( String message )
     {
         setErrorMessage( message );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/wizards/messages.properties
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/wizards/messages.properties?view=diff&rev=520897&r1=520896&r2=520897
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/wizards/messages.properties
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/wizards/messages.properties
Wed Mar 21 07:19:46 2007
@@ -44,4 +44,4 @@
 CreateANewObjectClassWizardPage.An_element_of_the_same_OID_already_exists=An element of the
same OID already exists
 CreateANewAttributeTypeWizardPage.An_element_of_the_same_name_already_exists=An element of
the same name already exists
 CreateANewSchemaWizardPage.A_schema_of_the_same_name_is_already_loaded_in_the_pool=A schema
of the same name is already loaded in the pool
-CreateANewObjectClassWizardPage.An_object_class_of_the_same_name_already_exists=An object
class of the same name already exists
+CreateANewObjectClassWizardPage.An_element_of_the_same_name_already_exists=An element of
the same name already exists



Mime
View raw message