directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r571492 - in /directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view: editors/schema/ wizards/
Date Fri, 31 Aug 2007 15:23:42 GMT
Author: pamarcelot
Date: Fri Aug 31 08:23:41 2007
New Revision: 571492

URL: http://svn.apache.org/viewvc?rev=571492&view=rev
Log:
Fixed a NPE in the Schema Editor.
Added "(None)" syntax and matching rules to the NewAttributeTypeWizard.

Modified:
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditor.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java
    directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditor.java?rev=571492&r1=571491&r2=571492&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditor.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditor.java
Fri Aug 31 08:23:41 2007
@@ -83,9 +83,9 @@
         setInput( input );
         setPartName( input.getName() );
 
-        Activator.getDefault().getSchemaHandler().addListener( schemaHandlerListener );
-
         schema = ( ( SchemaEditorInput ) getEditorInput() ).getSchema();
+
+        Activator.getDefault().getSchemaHandler().addListener( schemaHandlerListener );
     }
 
 

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java?rev=571492&r1=571491&r2=571492&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorOverviewPage.java
Fri Aug 31 08:23:41 2007
@@ -210,7 +210,6 @@
     {
         // Getting the associated schema
         schema = ( ( SchemaEditor ) getEditor() ).getSchema();
-        schemaHandler.addListener( schema, schemaListener );
 
         // Creating the base UI
         ScrolledForm form = managedForm.getForm();
@@ -305,11 +304,34 @@
 
 
     /**
-     * Initializes and adds the listners.
+     * Initializes and adds the listeners.
      */
     private void addListeners()
     {
+        schemaHandler.addListener( schema, schemaListener );
         attributeTypesTableViewer.addDoubleClickListener( attributeTypesTableViewerListener
);
         objectClassesTableViewer.addDoubleClickListener( objectClassesTableViewerListener
);
+    }
+
+
+    /**
+     * Removes the listeners.
+     */
+    private void removeListeners()
+    {
+        schemaHandler.removeListener( schema, schemaListener );
+        attributeTypesTableViewer.removeDoubleClickListener( attributeTypesTableViewerListener
);
+        objectClassesTableViewer.removeDoubleClickListener( objectClassesTableViewerListener
);
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormPage#dispose()
+     */
+    public void dispose()
+    {
+        removeListeners();
+
+        super.dispose();
     }
 }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java?rev=571492&r1=571491&r2=571492&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/editors/schema/SchemaEditorSourceCodePage.java
Fri Aug 31 08:23:41 2007
@@ -194,7 +194,6 @@
     protected void createFormContent( IManagedForm managedForm )
     {
         schema = ( ( SchemaEditor ) getEditor() ).getSchema();
-        Activator.getDefault().getSchemaHandler().addListener( schema, schemaListener );
 
         ScrolledForm form = managedForm.getForm();
         FormToolkit toolkit = managedForm.getToolkit();
@@ -219,6 +218,8 @@
 
         // Initializes the UI from the schema
         fillInUiFields();
+
+        addListeners();
     }
 
 
@@ -228,5 +229,34 @@
     private void fillInUiFields()
     {
         schemaSourceViewer.getDocument().set( OpenLdapSchemaFileExporter.toSourceCode( schema
) );
+    }
+
+
+    /**
+     * Adds the listeners.
+     */
+    private void addListeners()
+    {
+        Activator.getDefault().getSchemaHandler().addListener( schema, schemaListener );
+    }
+
+
+    /**
+     * Removes the listeners.
+     */
+    private void removeListeners()
+    {
+        Activator.getDefault().getSchemaHandler().removeListener( schema, schemaListener
);
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormPage#dispose()
+     */
+    public void dispose()
+    {
+        removeListeners();
+
+        super.dispose();
     }
 }

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java?rev=571492&r1=571491&r2=571492&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeContentWizardPage.java
Fri Aug 31 08:23:41 2007
@@ -236,38 +236,52 @@
     /**
      * Initializes the UI fields.
      */
+    @SuppressWarnings("unchecked")
     private void initFields()
     {
         if ( schemaHandler != null )
         {
             // Getting the syntaxes
-            List<SyntaxImpl> syntaxes = new ArrayList<SyntaxImpl>( schemaHandler.getSyntaxes()
);
+            List<Object> syntaxes = new ArrayList( schemaHandler.getSyntaxes() );
+            // Adding the (None) Syntax
+            String none = "(None)";
+            syntaxes.add( none );
 
             // Sorting the syntaxes
-            Collections.sort( syntaxes, new Comparator<SyntaxImpl>()
+            Collections.sort( syntaxes, new Comparator<Object>()
             {
-
-                public int compare( SyntaxImpl o1, SyntaxImpl o2 )
+                public int compare( Object o1, Object o2 )
                 {
-                    String[] o1Names = o1.getNames();
-                    String[] o2Names = o2.getNames();
-
-                    // Comparing the First Name
-                    if ( ( o1Names != null ) && ( o2Names != null ) )
+                    if ( ( o1 instanceof SyntaxImpl ) && ( o2 instanceof SyntaxImpl
) )
                     {
-                        if ( ( o1Names.length > 0 ) && ( o2Names.length > 0
) )
-                        {
-                            return o1Names[0].compareToIgnoreCase( o2Names[0] );
-                        }
-                        else if ( ( o1Names.length == 0 ) && ( o2Names.length >
0 ) )
-                        {
-                            return "".compareToIgnoreCase( o2Names[0] );
-                        }
-                        else if ( ( o1Names.length > 0 ) && ( o2Names.length ==
0 ) )
+                        String[] o1Names = ( ( SyntaxImpl ) o1 ).getNames();
+                        String[] o2Names = ( ( SyntaxImpl ) o2 ).getNames();
+
+                        // Comparing the First Name
+                        if ( ( o1Names != null ) && ( o2Names != null ) )
                         {
-                            return o1Names[0].compareToIgnoreCase( "" );
+                            if ( ( o1Names.length > 0 ) && ( o2Names.length >
0 ) )
+                            {
+                                return o1Names[0].compareToIgnoreCase( o2Names[0] );
+                            }
+                            else if ( ( o1Names.length == 0 ) && ( o2Names.length
> 0 ) )
+                            {
+                                return "".compareToIgnoreCase( o2Names[0] );
+                            }
+                            else if ( ( o1Names.length > 0 ) && ( o2Names.length
== 0 ) )
+                            {
+                                return o1Names[0].compareToIgnoreCase( "" );
+                            }
                         }
                     }
+                    else if ( ( o1 instanceof String ) && ( o2 instanceof SyntaxImpl
) )
+                    {
+                        return Integer.MIN_VALUE;
+                    }
+                    else if ( ( o1 instanceof SyntaxImpl ) && ( o2 instanceof String
) )
+                    {
+                        return Integer.MAX_VALUE;
+                    }
 
                     // Default
                     return o1.toString().compareToIgnoreCase( o2.toString() );
@@ -276,6 +290,7 @@
 
             // Setting the input
             syntaxComboViewer.setInput( syntaxes );
+            syntaxComboViewer.setSelection( new StructuredSelection( none ) );
         }
     }
 
@@ -381,11 +396,11 @@
      */
     public String getSyntax()
     {
-        SyntaxImpl syntax = ( SyntaxImpl ) ( ( StructuredSelection ) syntaxComboViewer.getSelection()
)
-            .getFirstElement();
-        if ( syntax != null )
+        Object selection = ( ( StructuredSelection ) syntaxComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof SyntaxImpl )
         {
-            return syntax.getOid();
+            return ( ( SyntaxImpl ) selection ).getOid();
         }
 
         return null;

Modified: directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java?rev=571492&r1=571491&r2=571492&view=diff
==============================================================================
--- directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java
(original)
+++ directory/studio/trunk/studio-schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewAttributeTypeMatchingRulesWizardPage.java
Fri Aug 31 08:23:41 2007
@@ -157,36 +157,51 @@
     /**
      * Initializes the UI fields.
      */
+    @SuppressWarnings("unchecked")
     private void initFields()
     {
         if ( schemaHandler != null )
         {
             // Getting the matching rules
-            List<MatchingRuleImpl> matchingRules = new ArrayList<MatchingRuleImpl>(
schemaHandler.getMatchingRules() );
+            List<Object> matchingRules = new ArrayList( schemaHandler.getMatchingRules()
);
+            // Adding the (None) matching rule
+            String none = "(None)";
+            matchingRules.add( none );
 
             // Sorting the matching rules
-            Collections.sort( matchingRules, new Comparator<MatchingRuleImpl>()
+            Collections.sort( matchingRules, new Comparator<Object>()
             {
 
-                public int compare( MatchingRuleImpl o1, MatchingRuleImpl o2 )
+                public int compare( Object o1, Object o2 )
                 {
-                    String[] o1Names = o1.getNames();
-                    String[] o2Names = o2.getNames();
-
-                    // Comparing the First Name
-                    if ( ( o1Names != null ) && ( o2Names != null ) )
+                    if ( ( o1 instanceof MatchingRuleImpl ) && ( o2 instanceof MatchingRuleImpl
) )
                     {
-                        if ( ( o1Names.length > 0 ) && ( o2Names.length > 0
) )
+                        String[] o1Names = ( ( MatchingRuleImpl ) o1 ).getNames();
+                        String[] o2Names = ( ( MatchingRuleImpl ) o2 ).getNames();
+
+                        // Comparing the First Name
+                        if ( ( o1Names != null ) && ( o2Names != null ) )
                         {
-                            return o1Names[0].compareToIgnoreCase( o2Names[0] );
+                            if ( ( o1Names.length > 0 ) && ( o2Names.length >
0 ) )
+                            {
+                                return o1Names[0].compareToIgnoreCase( o2Names[0] );
+                            }
+                            else if ( ( o1Names.length == 0 ) && ( o2Names.length
> 0 ) )
+                            {
+                                return "".compareToIgnoreCase( o2Names[0] );
+                            }
+                            else if ( ( o1Names.length > 0 ) && ( o2Names.length
== 0 ) )
+                            {
+                                return o1Names[0].compareToIgnoreCase( "" );
+                            }
                         }
-                        else if ( ( o1Names.length == 0 ) && ( o2Names.length >
0 ) )
+                        else if ( ( o1 instanceof String ) && ( o2 instanceof MatchingRuleImpl
) )
                         {
-                            return "".compareToIgnoreCase( o2Names[0] );
+                            return Integer.MIN_VALUE;
                         }
-                        else if ( ( o1Names.length > 0 ) && ( o2Names.length ==
0 ) )
+                        else if ( ( o1 instanceof MatchingRuleImpl ) && ( o2 instanceof
String ) )
                         {
-                            return o1Names[0].compareToIgnoreCase( "" );
+                            return Integer.MAX_VALUE;
                         }
                     }
 
@@ -199,6 +214,11 @@
             equalityComboViewer.setInput( matchingRules );
             orderingComboViewer.setInput( matchingRules );
             substringComboViewer.setInput( matchingRules );
+
+            // Selecting the None matching rules
+            equalityComboViewer.setSelection( new StructuredSelection( none ) );
+            orderingComboViewer.setSelection( new StructuredSelection( none ) );
+            substringComboViewer.setSelection( new StructuredSelection( none ) );
         }
     }
 
@@ -211,10 +231,12 @@
      */
     public String getEqualityMatchingRuleValue()
     {
-        MatchingRuleImpl mr = ( MatchingRuleImpl ) ( ( StructuredSelection ) equalityComboViewer.getSelection()
)
-            .getFirstElement();
-        if ( mr != null )
+        Object selection = ( ( StructuredSelection ) equalityComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof MatchingRuleImpl )
         {
+            MatchingRuleImpl mr = ( ( MatchingRuleImpl ) selection );
+
             String[] names = mr.getNames();
             if ( ( names != null ) && ( names.length > 0 ) )
             {
@@ -238,10 +260,12 @@
      */
     public String getOrderingMatchingRuleValue()
     {
-        MatchingRuleImpl mr = ( MatchingRuleImpl ) ( ( StructuredSelection ) orderingComboViewer.getSelection()
)
-            .getFirstElement();
-        if ( mr != null )
+        Object selection = ( ( StructuredSelection ) orderingComboViewer.getSelection() ).getFirstElement();
+
+        if ( selection instanceof MatchingRuleImpl )
         {
+            MatchingRuleImpl mr = ( ( MatchingRuleImpl ) selection );
+
             String[] names = mr.getNames();
             if ( ( names != null ) && ( names.length > 0 ) )
             {
@@ -265,10 +289,12 @@
      */
     public String getSubstringMatchingRuleValue()
     {
-        MatchingRuleImpl mr = ( MatchingRuleImpl ) ( ( StructuredSelection ) substringComboViewer.getSelection()
)
-            .getFirstElement();
-        if ( mr != null )
+        Object selection = ( ( StructuredSelection ) substringComboViewer.getSelection()
).getFirstElement();
+
+        if ( selection instanceof MatchingRuleImpl )
         {
+            MatchingRuleImpl mr = ( ( MatchingRuleImpl ) selection );
+
             String[] names = mr.getNames();
             if ( ( names != null ) && ( names.length > 0 ) )
             {



Mime
View raw message