directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r522454 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view: dialogs/ editors/attributeType/ editors/objectClass/
Date Mon, 26 Mar 2007 08:39:19 GMT
Author: pamarcelot
Date: Mon Mar 26 01:39:18 2007
New Revision: 522454

URL: http://svn.apache.org/viewvc?view=rev&rev=522454
Log:
Disabled Manage Aliases Button when AT/OC is from a Core Schema.
Refactored the Manage Aliases Dialog Class.

Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/dialogs/ManageAliasesDialog.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/attributeType/AttributeTypeEditorOverviewPage.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/objectClass/ObjectClassEditorOverviewPage.java

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/dialogs/ManageAliasesDialog.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/dialogs/ManageAliasesDialog.java?view=diff&rev=522454&r1=522453&r2=522454
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/dialogs/ManageAliasesDialog.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/dialogs/ManageAliasesDialog.java
Mon Mar 26 01:39:18 2007
@@ -69,9 +69,6 @@
     private List<String> aliases;
     private List<String> aliasesLowerCased;
 
-    /** The flag for disabling editing */
-    private boolean disableEditing;
-
     /** The dirty flag */
     private boolean dirty = false;
 
@@ -87,16 +84,12 @@
     /**
      * 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 )
+    public ManageAliasesDialog( String[] aliases )
     {
-        super( parent );
+        super( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() );
         this.aliases = new ArrayList<String>();
         aliasesLowerCased = new ArrayList<String>();
         for ( String alias : aliases )
@@ -104,7 +97,6 @@
             this.aliases.add( alias );
             aliasesLowerCased.add( alias.toLowerCase() );
         }
-        this.disableEditing = disableEditing;
     }
 
 
@@ -203,101 +195,93 @@
      */
     private void initListeners()
     {
-        if ( this.disableEditing )
-        {
-            aliasesTable.setEnabled( false );
-            newAliasText.setEnabled( false );
-            newAliasAddButton.setEnabled( false );
-        }
-        else
+        aliasesTable.addKeyListener( new KeyListener()
         {
-            aliasesTable.addKeyListener( new KeyListener()
+            public void keyPressed( KeyEvent e )
             {
-                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.
+                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.
 
-                        removeAliases();
-                    }
+                    removeAliases();
                 }
+            }
 
 
-                public void keyReleased( KeyEvent e )
-                {
-                }
-            } );
-
-            // Aliases Table's Popup Menu
-            Menu menu = new Menu( getShell(), SWT.POP_UP );
-            aliasesTable.setMenu( menu );
-            MenuItem deleteMenuItem = new MenuItem( menu, SWT.PUSH );
-            deleteMenuItem.setText( Messages.getString( "ManageAliasesDialog.Delete" ) );
//$NON-NLS-1$
-            deleteMenuItem.setImage( PlatformUI.getWorkbench().getSharedImages().getImage(
ISharedImages.IMG_TOOL_DELETE ) );
-            // Adding the listener
-            deleteMenuItem.addListener( SWT.Selection, new Listener()
+            public void keyReleased( KeyEvent e )
             {
-                public void handleEvent( Event event )
-                {
-                    removeAliases();
-                }
-            } );
+            }
+        } );
 
-            // NEW ALIAS Field
-            newAliasText.addTraverseListener( new TraverseListener()
+        // Aliases Table's Popup Menu
+        Menu menu = new Menu( getShell(), SWT.POP_UP );
+        aliasesTable.setMenu( menu );
+        MenuItem deleteMenuItem = new MenuItem( menu, SWT.PUSH );
+        deleteMenuItem.setText( Messages.getString( "ManageAliasesDialog.Delete" ) ); //$NON-NLS-1$
+        deleteMenuItem.setImage( PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_TOOL_DELETE
) );
+        // Adding the listener
+        deleteMenuItem.addListener( SWT.Selection, new Listener()
+        {
+            public void handleEvent( Event event )
             {
-                public void keyTraversed( TraverseEvent e )
-                {
-                    if ( e.detail == SWT.TRAVERSE_RETURN )
-                    {
-                        String text = newAliasText.getText();
+                removeAliases();
+            }
+        } );
 
-                        if ( ( !"".equals( text ) ) && ( !aliasesLowerCased.contains(
text.toLowerCase() ) )
-                            && ( !SchemaPool.getInstance().containsSchemaElement(
text ) ) )
-                        {
-                            addANewAlias();
-                        }
-                    }
-                }
-            } );
-
-            newAliasText.addModifyListener( new ModifyListener()
+        // NEW ALIAS Field
+        newAliasText.addTraverseListener( new TraverseListener()
+        {
+            public void keyTraversed( TraverseEvent e )
             {
-                public void modifyText( ModifyEvent e )
+                if ( e.detail == SWT.TRAVERSE_RETURN )
                 {
-                    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().containsSchemaElement( text ) )
+                    if ( ( !"".equals( text ) ) && ( !aliasesLowerCased.contains(
text.toLowerCase() ) )
+                        && ( !SchemaPool.getInstance().containsSchemaElement( text
) ) )
                     {
-                        errorComposite.setVisible( true );
-                        errorLabel.setText( "An element with same alias already exists."
);
-                        newAliasAddButton.setEnabled( false );
+                        addANewAlias();
                     }
                 }
-            } );
+            }
+        } );
 
-            // ADD Button
-            newAliasAddButton.addSelectionListener( new SelectionAdapter()
+        newAliasText.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
             {
-                public void widgetSelected( SelectionEvent e )
+                errorComposite.setVisible( false );
+                newAliasAddButton.setEnabled( true );
+                String text = newAliasText.getText();
+
+                if ( "".equals( text ) )
                 {
-                    addANewAlias();
+                    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().containsSchemaElement( text ) )
+                {
+                    errorComposite.setVisible( true );
+                    errorLabel.setText( "An element with same alias already exists." );
+                    newAliasAddButton.setEnabled( false );
+                }
+            }
+        } );
+
+        // ADD Button
+        newAliasAddButton.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                addANewAlias();
+            }
+        } );
+
     }
 
 
@@ -340,10 +324,7 @@
     protected void createButtonsForButtonBar( Composite parent )
     {
         createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false );
-        if ( !disableEditing )
-        {
-            createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
-        }
+        createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL,
false );
     }
 
 

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/attributeType/AttributeTypeEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/attributeType/AttributeTypeEditorOverviewPage.java?view=diff&rev=522454&r1=522453&r2=522454
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/attributeType/AttributeTypeEditorOverviewPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/attributeType/AttributeTypeEditorOverviewPage.java
Mon Mar 26 01:39:18 2007
@@ -120,8 +120,7 @@
     {
         public void widgetSelected( SelectionEvent e )
         {
-            ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, modifiedAttributeType.getNames(),
-                ( modifiedAttributeType.getOriginatingSchema().type == Schema.SchemaType.coreSchema
) );
+            ManageAliasesDialog manageDialog = new ManageAliasesDialog( modifiedAttributeType.getNames()
);
             if ( manageDialog.open() != Window.OK )
             {
                 return;
@@ -778,7 +777,7 @@
     private void fillSupCombo()
     {
         supComboViewer.setInput( new ATESuperiorComboInput( originalAttributeType ) );
-        
+
         if ( modifiedAttributeType.getSuperior() == null )
         {
             supComboViewer.setSelection( new StructuredSelection( new NonExistingAttributeType(
@@ -838,7 +837,7 @@
     private void fillSyntaxCombo()
     {
         syntaxComboViewer.setInput( new ATESyntaxComboInput() );
-        
+
         if ( modifiedAttributeType.getSyntax() == null )
         {
             syntaxComboViewer.setSelection( new StructuredSelection( new NonExistingSyntax(
NonExistingSyntax.NONE ) ),
@@ -874,7 +873,7 @@
     private void fillEqualityCombo()
     {
         equalityComboViewer.setInput( new ATEMatchingRulesComboInput() );
-        
+
         if ( modifiedAttributeType.getEquality() == null )
         {
             equalityComboViewer.setSelection( new StructuredSelection( new NonExistingMatchingRule(
@@ -910,7 +909,7 @@
     private void fillOrderingCombo()
     {
         orderingComboViewer.setInput( new ATEMatchingRulesComboInput() );
-        
+
         if ( modifiedAttributeType.getOrdering() == null )
         {
             orderingComboViewer.setSelection( new StructuredSelection( new NonExistingMatchingRule(
@@ -947,7 +946,7 @@
     private void fillSubstringCombo()
     {
         substringComboViewer.setInput( new ATEMatchingRulesComboInput() );
-        
+
         if ( modifiedAttributeType.getSubstr() == null )
         {
             substringComboViewer.setSelection( new StructuredSelection( new NonExistingMatchingRule(
@@ -985,6 +984,7 @@
         if ( modifiedAttributeType.getOriginatingSchema().type == Schema.SchemaType.coreSchema
)
         {
             // If the attribute type is in a core-schema file, we disable editing
+            aliasesButton.setEnabled( false );
             oidText.setEditable( false );
             descriptionText.setEditable( false );
             supCombo.setEnabled( false );

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/objectClass/ObjectClassEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/objectClass/ObjectClassEditorOverviewPage.java?view=diff&rev=522454&r1=522453&r2=522454
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/objectClass/ObjectClassEditorOverviewPage.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/editors/objectClass/ObjectClassEditorOverviewPage.java
Mon Mar 26 01:39:18 2007
@@ -125,8 +125,7 @@
     {
         public void widgetSelected( SelectionEvent e )
         {
-            ManageAliasesDialog manageDialog = new ManageAliasesDialog( null, modifiedObjectClass.getNames(),
-                ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema
) );
+            ManageAliasesDialog manageDialog = new ManageAliasesDialog( modifiedObjectClass.getNames()
);
             if ( manageDialog.open() != Window.OK )
             {
                 return;
@@ -979,6 +978,7 @@
         if ( modifiedObjectClass.getOriginatingSchema().type == Schema.SchemaType.coreSchema
)
         {
             // If the object class is in a core-schema file, we disable editing
+            aliasesButton.setEnabled( false );
             oidText.setEditable( false );
             descriptionText.setEditable( false );
             addButtonSuperiorsTable.setEnabled( false );



Mime
View raw message