directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r520430 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main: java/org/apache/directory/ldapstudio/schemas/view/ java/org/apache/directory/ldapstudio/schemas/view/editors/ resources/org/apache/directory/ldapstudio/schemas/vie...
Date Tue, 20 Mar 2007 15:25:38 GMT
Author: pamarcelot
Date: Tue Mar 20 08:25:37 2007
New Revision: 520430

URL: http://svn.apache.org/viewvc?view=rev&rev=520430
Log:
Updated the Manage Aliases Dialog in the AT and OC Editors.

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/ManageAliasesDialog.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/resources/org/apache/directory/ldapstudio/schemas/view/editors/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=520430&r1=520429&r2=520430
==============================================================================
--- 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
Tue Mar 20 08:25:37 2007
@@ -39,13 +39,14 @@
     public static String concateAliases( String[] aliases )
     {
         StringBuffer sb = new StringBuffer();
-
-        sb.append( aliases[0] );
-
-        for ( int i = 1; i < aliases.length; i++ )
+        if ( aliases.length > 0 )
         {
-            sb.append( ", " );
-            sb.append( aliases[i] );
+            sb.append( aliases[0] );
+            for ( int i = 1; i < aliases.length; i++ )
+            {
+                sb.append( ", " );
+                sb.append( aliases[i] );
+            }
         }
 
         return sb.toString();

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=520430&r1=520429&r2=520430
==============================================================================
--- 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
Tue Mar 20 08:25:37 2007
@@ -34,6 +34,7 @@
 import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 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.ldap.schema.UsageEnum;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.window.Window;
@@ -80,8 +81,7 @@
     private AttributeType modifiedAttributeType;
 
     // UI Fields
-    private Text nameText;
-    private String[] aliasesList;
+    private Label aliasesLabel;
     private Button aliasesButton;
     private Text oidText;
     private Hyperlink schemaLink;
@@ -101,44 +101,28 @@
     private Combo substringCombo;
 
     // Listeners
-
-    /** The listener for the Name Text Widget*/
-    private ModifyListener nameTextListener = new ModifyListener()
-    {
-        public void modifyText( ModifyEvent e )
-        {
-            ArrayList<String> names = new ArrayList<String>();
-            names.add( nameText.getText() );
-            for ( int i = 0; i < aliasesList.length; i++ )
-            {
-                names.add( aliasesList[i] );
-            }
-            modifiedAttributeType.setNames( names.toArray( new String[0] ) );
-            setEditorDirty();
-        }
-    };
-
-    /** The listener for the Aliases Button Widget */
+    /** The listener for the Manage Aliases Button Widget */
     private SelectionAdapter aliasesButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, aliasesList,
( modifiedAttributeType
-                .getOriginatingSchema().type == Schema.SchemaType.coreSchema ) );
+            ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, modifiedAttributeType.getNames(),
+                ( modifiedAttributeType.getOriginatingSchema().type == Schema.SchemaType.coreSchema
) );
             if ( manageDialog.open() != Window.OK )
             {
                 return;
             }
             if ( manageDialog.isDirty() )
             {
-                aliasesList = manageDialog.getAliasesList();
-                ArrayList<String> names = new ArrayList<String>();
-                names.add( modifiedAttributeType.getNames()[0] );
-                for ( int i = 0; i < aliasesList.length; i++ )
+                modifiedAttributeType.setNames( manageDialog.getAliases() );
+                if ( ( modifiedAttributeType.getNames() != null ) && ( modifiedAttributeType.getNames().length
!= 0 ) )
+                {
+                    aliasesLabel.setText( ViewUtils.concateAliases( modifiedAttributeType.getNames()
) );
+                }
+                else
                 {
-                    names.add( aliasesList[i] );
+                    aliasesLabel.setText( Messages.getString( "AttributeTypeFormEditorOverviewPage.(None)"
) );
                 }
-                modifiedAttributeType.setNames( names.toArray( new String[0] ) );
                 setEditorDirty();
             }
         }
@@ -153,7 +137,7 @@
             setEditorDirty();
         }
     };
-    
+
     /** The listener for the Schema Hyperlink Widget*/
     private HyperlinkAdapter schemaLinkListener = new HyperlinkAdapter()
     {
@@ -448,22 +432,19 @@
         client_general_information.setLayout( layout_general_information );
         toolkit.paintBordersFor( client_general_information );
         section_general_information.setClient( client_general_information );
-        section_general_information.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        section_general_information.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true,
true ) );
 
         // Adding elements to the section
-        // NAME Field
-        toolkit.createLabel( client_general_information, Messages
-            .getString( "AttributeTypeFormEditorOverviewPage.Name" ) ); //$NON-NLS-1$
-        nameText = toolkit.createText( client_general_information, "" ); //$NON-NLS-1$
-        nameText.setLayoutData( new GridData( SWT.FILL, 0, true, false, 2, 1 ) );
-
         // ALIASES Button
         toolkit.createLabel( client_general_information, Messages
             .getString( "AttributeTypeFormEditorOverviewPage.Aliases" ) ); //$NON-NLS-1$
+        aliasesLabel = toolkit.createLabel( client_general_information, "" );
+        aliasesLabel.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1
) );
+        toolkit.createLabel( client_general_information, "" );
         aliasesButton = toolkit.createButton( client_general_information, Messages
-            .getString( "AttributeTypeFormEditorOverviewPage.Manage_aliases" ), SWT.PUSH
); //$NON-NLS-1$
-        aliasesButton.setLayoutData( new GridData( SWT.NONE, SWT.BEGINNING, false, false,
2, 1 ) );
-
+            .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$
@@ -473,7 +454,7 @@
         {
             public void verifyText( VerifyEvent e )
             {
-                if ( e.text.length() < 20  && !e.text.matches( "([0-9]+\\.?)*"
) )
+                if ( e.text.length() < 20 && !e.text.matches( "([0-9]+\\.?)*"
) )
                 {
                     e.doit = false;
                 }
@@ -568,7 +549,7 @@
         client_matching_rules.setLayout( layout_matching_rules );
         toolkit.paintBordersFor( client_matching_rules );
         section_matching_rules.setClient( client_matching_rules );
-        section_matching_rules.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        section_matching_rules.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true
) );
 
         // EQUALITY Combo
         toolkit
@@ -683,21 +664,15 @@
 
     private void fillInUiFields()
     {
-        // NAME Field
-        if ( modifiedAttributeType.getNames()[0] != null )
+        // ALIASES Label
+        if ( ( modifiedAttributeType.getNames() != null ) && ( modifiedAttributeType.getNames().length
!= 0 ) )
         {
-            this.nameText.setText( modifiedAttributeType.getNames()[0] );
+            aliasesLabel.setText( ViewUtils.concateAliases( modifiedAttributeType.getNames()
) );
         }
-
-        // ALIASES
-        String[] names = modifiedAttributeType.getNames();
-        ArrayList<String> aliases = new ArrayList<String>();
-        for ( int i = 1; i < names.length; i++ )
+        else
         {
-            String name = names[i];
-            aliases.add( name );
+            aliasesLabel.setText( Messages.getString( "AttributeTypeFormEditorOverviewPage.(None)"
) );
         }
-        this.aliasesList = aliases.toArray( new String[0] );
 
         // OID Field
         if ( modifiedAttributeType.getOid() != null )
@@ -928,7 +903,6 @@
         if ( modifiedAttributeType.getOriginatingSchema().type == Schema.SchemaType.coreSchema
)
         {
             // If the attribute type is in a core-schema file, we disable editing
-            nameText.setEditable( false );
             oidText.setEditable( false );
             descriptionText.setEditable( false );
             supCombo.setEnabled( false );
@@ -953,7 +927,6 @@
     {
         if ( modifiedAttributeType.getOriginatingSchema().type == Schema.SchemaType.userSchema
)
         {
-            nameText.addModifyListener( nameTextListener );
             oidText.addModifyListener( oidTextListener );
             descriptionText.addModifyListener( descriptionTextListener );
             supLabel.addHyperlinkListener( supLabelListener );
@@ -983,7 +956,6 @@
      */
     private void removeListeners()
     {
-        nameText.removeModifyListener( nameTextListener );
         oidText.removeModifyListener( oidTextListener );
         aliasesButton.removeSelectionListener( aliasesButtonListener );
         schemaLink.removeHyperlinkListener( schemaLinkListener );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ManageAliasesDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ManageAliasesDialog.java?view=diff&rev=520430&r1=520429&r2=520430
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ManageAliasesDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/ManageAliasesDialog.java
Tue Mar 20 08:25:37 2007
@@ -22,17 +22,22 @@
 
 
 import java.util.ArrayList;
+import java.util.List;
 
+import org.apache.directory.ldapstudio.schemas.model.SchemaPool;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.TraverseEvent;
 import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -47,27 +52,64 @@
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
 
 
+/**
+ * This class implements the Manage Aliases Dialog.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
 public class ManageAliasesDialog extends Dialog
 {
+    /** The aliases List */
+    private List<String> aliases;
+    private List<String> aliasesLowerCased;
 
-    private Table aliases_table;
-    private Text newAlias_text;
-    private Button newAlias_button;
-    private String[] aliasesList;
+    /** The flag for disabling editing */
     private boolean disableEditing;
-    private boolean dirty = false;
 
+    /** The dirty flag */
+    private boolean dirty = false;
 
-    public ManageAliasesDialog( Shell parent, String[] list, boolean disableEditing )
+    // UI Fields
+    private Table aliasesTable;
+    private Text newAliasText;
+    private Button newAliasAddButton;
+    private Composite errorComposite;
+    private Image errorImage;
+    private Label errorLabel;
+
+
+    /**
+     * Creates a new instance of ManageAliasesDialog.
+     *
+     * @param parent
+     *      the parent shell
+     * @param aliases
+     *      the array containing the aliases
+     * @param disableEditing
+     *      the boolean to disable editing
+     */
+    public ManageAliasesDialog( Shell parent, String[] aliases, boolean disableEditing )
     {
         super( parent );
-        this.aliasesList = list;
+        this.aliases = new ArrayList<String>();
+        aliasesLowerCased = new ArrayList<String>();
+        for ( String alias : aliases )
+        {
+            this.aliases.add( alias );
+            aliasesLowerCased.add( alias.toLowerCase() );
+        }
         this.disableEditing = disableEditing;
     }
 
 
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
     protected void configureShell( Shell newShell )
     {
         super.configureShell( newShell );
@@ -75,13 +117,13 @@
     }
 
 
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
     protected Control createDialogArea( Composite parent )
     {
         Composite composite = new Composite( parent, SWT.NONE );
-        GridLayout layout = new GridLayout( 2, false );
-        layout.marginHeight = 10;
-        layout.marginWidth = 10;
-        composite.setLayout( layout );
+        composite.setLayout( new GridLayout( 2, false ) );
         composite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true )
);
 
         // ALIASES Label
@@ -90,14 +132,14 @@
         aliases_label.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, true, 2,
1 ) );
 
         // ALIASES Table
-        aliases_table = new Table( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
| SWT.FULL_SELECTION
+        aliasesTable = new Table( composite, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
| SWT.FULL_SELECTION
             | SWT.HIDE_SELECTION );
         GridData gridData = new GridData( GridData.FILL, GridData.FILL, true, true, 2, 1
);
         gridData.heightHint = 100;
         gridData.minimumHeight = 100;
-        gridData.widthHint = 200;
-        gridData.minimumWidth = 200;
-        aliases_table.setLayoutData( gridData );
+        gridData.widthHint = 250;
+        gridData.minimumWidth = 250;
+        aliasesTable.setLayoutData( gridData );
 
         // ADD Label
         Label add_label = new Label( composite, SWT.NONE );
@@ -105,57 +147,78 @@
         add_label.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, true, 2, 1
) );
 
         // NEW ALIAS Field
-        newAlias_text = new Text( composite, SWT.BORDER );
-        newAlias_text.setLayoutData( new GridData( GridData.FILL, SWT.CENTER, true, false
) );
+        newAliasText = new Text( composite, SWT.BORDER );
+        newAliasText.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true
) );
 
         // Add Button
-        newAlias_button = new Button( composite, SWT.PUSH );
-        newAlias_button.setText( Messages.getString( "ManageAliasesDialog.Add" ) ); //$NON-NLS-1$
+        newAliasAddButton = new Button( composite, SWT.PUSH );
+        newAliasAddButton.setText( Messages.getString( "ManageAliasesDialog.Add" ) ); //$NON-NLS-1$
+        newAliasAddButton.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false )
);
+        newAliasAddButton.setEnabled( false );
+
+        errorComposite = new Composite( composite, SWT.NONE );
+        errorComposite.setLayout( new GridLayout( 2, false ) );
+        errorComposite.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true
) );
+        errorComposite.setVisible( false );
+
+        errorImage = PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_ERROR_TSK
);
+        Label label = new Label( errorComposite, SWT.NONE );
+        label.setImage( errorImage );
+        label.setSize( 16, 16 );
+
+        errorLabel = new Label( errorComposite, SWT.NONE );
+        errorLabel.setText( "An element with same alias already exists." );
+        errorLabel.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, true
) );
 
         // Table initialization
-        initAliases_table();
+        fillAliasesTable();
 
         // Listeners initialization
         initListeners();
 
         // Setting the focus to the text field
-        newAlias_text.setFocus();
+        newAliasText.setFocus();
 
         return composite;
     }
 
 
-    private void initAliases_table()
+    /**
+     * Fills in the Aliases Table from the aliases list     */
+    private void fillAliasesTable()
     {
-        for ( int i = 0; i < aliasesList.length; i++ )
+        aliasesTable.removeAll();
+        aliasesTable.setItemCount( 0 );
+        for ( String alias : aliases )
         {
-            String aliasName = aliasesList[i];
-            TableItem newItem = new TableItem( aliases_table, SWT.NONE );
-            newItem.setText( aliasName );
+            TableItem newItem = new TableItem( aliasesTable, SWT.NONE );
+            newItem.setText( alias );
         }
     }
 
 
+    /**
+     * Initializes the Listeners.
+     */
     private void initListeners()
     {
         if ( this.disableEditing )
         {
-            aliases_table.setEnabled( false );
-            newAlias_text.setEnabled( false );
-            newAlias_button.setEnabled( false );
+            aliasesTable.setEnabled( false );
+            newAliasText.setEnabled( false );
+            newAliasAddButton.setEnabled( false );
         }
         else
         {
-            aliases_table.addKeyListener( new KeyListener()
+            aliasesTable.addKeyListener( new KeyListener()
             {
                 public void keyPressed( KeyEvent e )
                 {
                     if ( ( e.keyCode == SWT.DEL ) || ( e.keyCode == Action.findKeyCode( "BACKSPACE"
) ) ) { //$NON-NLS-1$
                         // NOTE: I couldn't find the corresponding Identificator in the SWT.SWT
Class,
                         // so I Used JFace Action fineKeyCode method to get the Backspace
keycode.
-                        aliases_table.remove( aliases_table.getSelectionIndices() );
-                        // Setting the Dialog has dirty
-                        dirty = true;
+
+                        removeAliases();
                     }
                 }
 
@@ -167,7 +230,7 @@
 
             // Aliases Table's Popup Menu
             Menu menu = new Menu( getShell(), SWT.POP_UP );
-            aliases_table.setMenu( menu );
+            aliasesTable.setMenu( menu );
             MenuItem deleteMenuItem = new MenuItem( menu, SWT.PUSH );
             deleteMenuItem.setText( Messages.getString( "ManageAliasesDialog.Delete" ) );
//$NON-NLS-1$
             // Adding the listener
@@ -175,26 +238,57 @@
             {
                 public void handleEvent( Event event )
                 {
-                    aliases_table.remove( aliases_table.getSelectionIndices() );
-                    // Setting the Dialog has dirty
-                    dirty = true;
+                    removeAliases();
                 }
             } );
 
             // NEW ALIAS Field
-            newAlias_text.addTraverseListener( new TraverseListener()
+            newAliasText.addTraverseListener( new TraverseListener()
             {
                 public void keyTraversed( TraverseEvent e )
                 {
                     if ( e.detail == SWT.TRAVERSE_RETURN )
                     {
-                        addANewAlias();
+                        String text = newAliasText.getText();
+
+                        if ( ( !"".equals( text ) ) && ( !aliasesLowerCased.contains(
text.toLowerCase() ) )
+                            && ( !SchemaPool.getInstance().getSchemaElements().containsKey(
text ) ) )
+                        {
+                            addANewAlias();
+                        }
+                    }
+                }
+            } );
+
+            newAliasText.addModifyListener( new ModifyListener()
+            {
+                public void modifyText( ModifyEvent e )
+                {
+                    errorComposite.setVisible( false );
+                    newAliasAddButton.setEnabled( true );
+                    String text = newAliasText.getText();
+
+                    if ( "".equals( text ) )
+                    {
+                        newAliasAddButton.setEnabled( false );
+                    }
+                    else if ( aliasesLowerCased.contains( text.toLowerCase() ) )
+                    {
+                        errorComposite.setVisible( true );
+                        errorLabel.setText( "This alias already exists in the list." );
+                        newAliasAddButton.setEnabled( false );
+                    }
+                    else if ( SchemaPool.getInstance().getSchemaElements().containsKey( text
) )
+                    {
+                        errorComposite.setVisible( true );
+                        errorLabel.setText( "An element with same alias already exists."
);
+                        newAliasAddButton.setEnabled( false );
                     }
                 }
             } );
 
             // ADD Button
-            newAlias_button.addSelectionListener( new SelectionAdapter()
+            newAliasAddButton.addSelectionListener( new SelectionAdapter()
             {
                 public void widgetSelected( SelectionEvent e )
                 {
@@ -205,52 +299,72 @@
     }
 
 
-    private void addANewAlias()
+    /**
+     * Removes the selected aliases in the Aliases Table from the Aliases List.
+     */
+    private void removeAliases()
     {
-        if ( newAlias_text.getText().length() != 0 )
+        TableItem[] selectedItems = aliasesTable.getSelection();
+        for ( TableItem item : selectedItems )
         {
-            TableItem newItem = new TableItem( aliases_table, SWT.NONE );
-            newItem.setText( newAlias_text.getText() );
-            newAlias_text.setText( "" ); //$NON-NLS-1$
-            aliases_table.deselectAll();
-            aliases_table.select( aliases_table.getItemCount() - 1 );
-            newAlias_text.setFocus();
-            // Setting the Dialog has dirty
-            this.dirty = true;
+            aliases.remove( item.getText() );
+            aliasesLowerCased.remove( item.getText().toLowerCase() );
         }
+        dirty = true;
+        fillAliasesTable();
     }
 
 
-    protected void createButtonsForButtonBar( Composite parent )
+    /**
+     * Adds a new alias
+     */
+    private void addANewAlias()
     {
-        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
-        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
+        if ( newAliasText.getText().length() != 0 )
+        {
+            aliases.add( newAliasText.getText() );
+            aliasesLowerCased.add( newAliasText.getText().toLowerCase() );
+            fillAliasesTable();
+            newAliasText.setText( "" );
+            newAliasText.setFocus();
+            this.dirty = true;
+        }
     }
 
 
-    protected void okPressed()
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar( Composite parent )
     {
-        // We create the new Array containing all the aliases
-        ArrayList<String> aliases = new ArrayList<String>();
-        for ( int i = 0; i < aliases_table.getItemCount(); i++ )
+        createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
+        if ( !disableEditing )
         {
-            aliases.add( aliases_table.getItem( i ).getText() );
+            createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
         }
-        // Then we store it
-        this.aliasesList = aliases.toArray( new String[0] );
-
-        super.okPressed();
     }
 
 
-    public String[] getAliasesList()
+    /**
+     * Returns the aliases.
+     *  
+     * @return
+     *      the aliases
+     */
+    public String[] getAliases()
     {
-        return aliasesList;
+        return aliases.toArray( new String[0] );
     }
 
 
+    /**
+     * Gets the Dirty flag of the dialog
+     *
+     * @return
+     *      the dirty flag of the dialog
+     */
     public boolean isDirty()
     {
-        return this.dirty;
+        return dirty;
     }
 }

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=520430&r1=520429&r2=520430
==============================================================================
--- 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
Tue Mar 20 08:25:37 2007
@@ -33,6 +33,7 @@
 import org.apache.directory.ldapstudio.schemas.model.ObjectClass;
 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.ldap.schema.ObjectClassTypeEnum;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -85,8 +86,7 @@
     private ObjectClass modifiedObjectClass;
 
     // UI fields
-    private Text nameText;
-    private String[] aliasesList;
+    private Label aliasesLabel;
     private Button aliasesButton;
     private Text oidText;
     private Hyperlink schemaLink;
@@ -104,43 +104,28 @@
     private Button removeButtonOptionalTable;
 
     // Listeners
-    /** The listener for Name Text Widget */
-    private ModifyListener nameTextListener = new ModifyListener()
-    {
-        public void modifyText( ModifyEvent e )
-        {
-            ArrayList<String> names = new ArrayList<String>();
-            names.add( nameText.getText() );
-            for ( int i = 0; i < aliasesList.length; i++ )
-            {
-                names.add( aliasesList[i] );
-            }
-            modifiedObjectClass.setNames( names.toArray( new String[0] ) );
-            setEditorDirty();
-        }
-    };
-
     /** The listener for Aliases Button Widget */
     private SelectionAdapter aliasesButtonListener = new SelectionAdapter()
     {
         public void widgetSelected( SelectionEvent e )
         {
-            ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, aliasesList,
( modifiedObjectClass
-                .getOriginatingSchema().type == Schema.SchemaType.coreSchema ) );
+            ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, modifiedObjectClass.getNames(),
+                ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema
) );
             if ( manageDialog.open() != Window.OK )
             {
                 return;
             }
             if ( manageDialog.isDirty() )
             {
-                aliasesList = manageDialog.getAliasesList();
-                ArrayList<String> names = new ArrayList<String>();
-                names.add( modifiedObjectClass.getNames()[0] );
-                for ( int i = 0; i < aliasesList.length; i++ )
+                modifiedObjectClass.setNames( manageDialog.getAliases() );
+                if ( ( modifiedObjectClass.getNames() != null ) && ( modifiedObjectClass.getNames().length
!= 0 ) )
+                {
+                    aliasesLabel.setText( ViewUtils.concateAliases( modifiedObjectClass.getNames()
) );
+                }
+                else
                 {
-                    names.add( aliasesList[i] );
+                    aliasesLabel.setText( Messages.getString( "AttributeTypeFormEditorOverviewPage.(None)"
) );
                 }
-                modifiedObjectClass.setNames( names.toArray( new String[0] ) );
                 setEditorDirty();
             }
         }
@@ -545,18 +530,15 @@
         section_general_information.setClient( client_general_information );
         section_general_information.setLayoutData( new GridData( GridData.FILL, GridData.FILL,
true, true, 2, 1 ) );
 
-        // NAME Field
-        toolkit
-            .createLabel( client_general_information, Messages.getString( "ObjectClassFormEditorOverviewPage.Name"
) ); //$NON-NLS-1$
-        nameText = toolkit.createText( client_general_information, "" ); //$NON-NLS-1$
-        nameText.setLayoutData( new GridData( GridData.FILL, SWT.NONE, true, false ) );
-
         // ALIASES Button
         toolkit.createLabel( client_general_information, Messages
             .getString( "ObjectClassFormEditorOverviewPage.Aliases" ) ); //$NON-NLS-1$
+        aliasesLabel = toolkit.createLabel( client_general_information, "" );
+        aliasesLabel.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
+        toolkit.createLabel( client_general_information, "" );
         aliasesButton = toolkit.createButton( client_general_information, Messages
-            .getString( "ObjectClassFormEditorOverviewPage.Manage_Aliases" ), SWT.PUSH );
//$NON-NLS-1$
-        aliasesButton.setLayoutData( new GridData( SWT.NONE, SWT.BEGINNING, false, false
) );
+            .getString( "AttributeTypeFormEditorOverviewPage.Manage_Aliases" ), SWT.PUSH
); //$NON-NLS-1$
+        aliasesButton.setLayoutData( new GridData( SWT.NONE, SWT.NONE, false, false ) );
 
         // OID Field
         toolkit.createLabel( client_general_information, Messages.getString( "ObjectClassFormEditorOverviewPage.OID"
) ); //$NON-NLS-1$
@@ -566,7 +548,7 @@
         {
             public void verifyText( VerifyEvent e )
             {
-                if ( e.text.length() < 20  && !e.text.matches( "([0-9]+\\.?)*"
) )
+                if ( e.text.length() < 20 && !e.text.matches( "([0-9]+\\.?)*"
) )
                 {
                     e.doit = false;
                 }
@@ -726,21 +708,15 @@
      */
     private void fillInUiFields()
     {
-        // NAME Field
-        if ( modifiedObjectClass.getNames()[0] != null )
+        // ALIASES Label
+        if ( ( modifiedObjectClass.getNames() != null ) && ( modifiedObjectClass.getNames().length
!= 0 ) )
         {
-            nameText.setText( modifiedObjectClass.getNames()[0] );
+            aliasesLabel.setText( ViewUtils.concateAliases( modifiedObjectClass.getNames()
) );
         }
-
-        // ALIASES
-        String[] names = modifiedObjectClass.getNames();
-        ArrayList<String> aliases = new ArrayList<String>();
-        for ( int i = 1; i < names.length; i++ )
+        else
         {
-            String name = names[i];
-            aliases.add( name );
+            aliasesLabel.setText( Messages.getString( "AttributeTypeFormEditorOverviewPage.(None)"
) );
         }
-        aliasesList = aliases.toArray( new String[0] );
 
         // OID Field
         if ( modifiedObjectClass.getOid() != null )
@@ -790,7 +766,7 @@
     private void initSupCombo()
     {
         SchemaPool pool = SchemaPool.getInstance();
-        List<ObjectClass> ocList =  pool.getObjectClasses();
+        List<ObjectClass> ocList = pool.getObjectClasses();
 
         //remove duplicate entries
         HashSet<ObjectClass> set = new HashSet<ObjectClass>( ocList );
@@ -868,8 +844,8 @@
         for ( int i = 0; i < mustArray.length; i++ )
         {
             TableItem item = new TableItem( mandatoryAttributesTable, SWT.NONE, i );
-            item.setImage( AbstractUIPlugin
-                .imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_ATTRIBUTE_TYPE
).createImage() );
+            item.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                PluginConstants.IMG_ATTRIBUTE_TYPE ).createImage() );
             item.setText( mustArray[i] );
             if ( ( selectionIndex != -1 ) && ( mustArray[i].equals( selectAttribute
) ) )
             {
@@ -897,8 +873,8 @@
         for ( int i = 0; i < mayArray.length; i++ )
         {
             TableItem item = new TableItem( optionalAttributesTable, SWT.NONE, i );
-            item.setImage( AbstractUIPlugin
-                .imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_ATTRIBUTE_TYPE
).createImage() );
+            item.setImage( AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
+                PluginConstants.IMG_ATTRIBUTE_TYPE ).createImage() );
             item.setText( mayArray[i] );
             if ( ( selectionIndex != -1 ) && ( mayArray[i].equals( selectAttribute
) ) )
             {
@@ -916,7 +892,6 @@
         if ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema
)
         {
             // If the object class is in a core-schema file, we disable editing
-            nameText.setEditable( false );
             oidText.setEditable( false );
             descriptionText.setEditable( false );
             supCombo.setEnabled( false );
@@ -942,7 +917,6 @@
     {
         if ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.userSchema
)
         {
-            nameText.addModifyListener( nameTextListener );
             oidText.addModifyListener( oidTextListener );
             descriptionText.addModifyListener( descriptionTextListener );
             supCombo.addModifyListener( supComboListener );
@@ -973,7 +947,6 @@
      */
     private void removeListeners()
     {
-        nameText.removeModifyListener( nameTextListener );
         aliasesButton.removeSelectionListener( aliasesButtonListener );
         oidText.removeModifyListener( oidTextListener );
         schemaLink.removeHyperlinkListener( schemaLinkListener );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/editors/messages.properties
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/editors/messages.properties?view=diff&rev=520430&r1=520429&r2=520430
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/editors/messages.properties
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/resources/org/apache/directory/ldapstudio/schemas/view/editors/messages.properties
Tue Mar 20 08:25:37 2007
@@ -30,9 +30,8 @@
 AttributeTypeFormEditorOverviewPage.General_Section_Description=Specify general information
(name, OID, etc.).
 AttributeTypeSelectionDialog.You_have_to_choose_an_attribute_type=You have to choose an attribute
type.
 AttributeTypeFormEditorOverviewPage.General_Section_Text=General information
-AttributeTypeFormEditorOverviewPage.Name=Name:
 AttributeTypeFormEditorOverviewPage.Aliases=Aliases:
-AttributeTypeFormEditorOverviewPage.Manage_aliases=Manage aliases
+AttributeTypeFormEditorOverviewPage.Manage_Aliases=Manage Aliases
 AttributeTypeFormEditorOverviewPage.OID=OID:
 AttributeTypeFormEditorOverviewPage.Description=Description:
 AttributeTypeFormEditorOverviewPage.Superior_type=Superior type:
@@ -64,7 +63,6 @@
 ObjectClassFormEditorInput.Schema=" schema
 ObjectClassFormEditorOverviewPage.General_Information_Section_Description=Specify general
information (name, OID, etc.).
 ObjectClassFormEditorOverviewPage.General_Information_Section_Text=General information
-ObjectClassFormEditorOverviewPage.Name=Name:
 ObjectClassFormEditorOverviewPage.Aliases=Aliases:
 ObjectClassFormEditorOverviewPage.Manage_Aliases=Manage aliases
 ObjectClassFormEditorOverviewPage.OID=OID:



Mime
View raw message