directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r520013 - in /directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view: ./ viewers/
Date Mon, 19 Mar 2007 16:55:47 GMT
Author: pamarcelot
Date: Mon Mar 19 09:55:46 2007
New Revision: 520013

URL: http://svn.apache.org/viewvc?view=rev&rev=520013
Log:
Small refactoring.

Added:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
Modified:
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsViewLabelProvider.java
    directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java

Added: 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=auto&rev=520013
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
(added)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/ViewUtils.java
Mon Mar 19 09:55:46 2007
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.ldapstudio.schemas.view;
+
+
+/**
+ * This Helper Class contains useful methods used to create the UI.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ViewUtils
+{
+    /**
+     * Concatenates all aliases in a String format. Aliases are separated with a comma (',')
+     *
+     * @param aliases
+     *      the aliases to concatenate
+     * @return
+     *      a String representing all aliases
+     */
+    public static String concateAliases( String[] aliases )
+    {
+        StringBuffer sb = new StringBuffer();
+
+        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/viewers/HierarchyViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java?view=diff&rev=520013&r1=520012&r2=520013
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/HierarchyViewLabelProvider.java
Mon Mar 19 09:55:46 2007
@@ -23,6 +23,7 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.view.ViewUtils;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
@@ -80,7 +81,7 @@
             }
             else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES
)
             {
-                label = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
+                label = ViewUtils.concateAliases( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
             }
             else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
             {
@@ -100,7 +101,7 @@
             }
             else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES
)
             {
-                label = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
+                label = ViewUtils.concateAliases( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
             }
             else if ( labelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID )
             {
@@ -139,7 +140,8 @@
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES
)
                 {
-                    secondaryLabel = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
+                    secondaryLabel = ViewUtils.concateAliases( ( ( AttributeTypeWrapper )
obj ).getMyAttributeType()
+                        .getNames() );
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID
)
                 {
@@ -154,7 +156,8 @@
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_ALL_ALIASES
)
                 {
-                    secondaryLabel = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
+                    secondaryLabel = ViewUtils.concateAliases( ( ( ObjectClassWrapper ) obj
).getMyObjectClass()
+                        .getNames() );
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_HIERARCHY_VIEW_LABEL_OID
)
                 {
@@ -186,29 +189,5 @@
 
         // Default
         return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK
);
-    }
-
-
-    /**
-     * Concatenates all aliases in a String format
-     *
-     * @param aliases
-     *      the aliases to concatenate
-     * @return
-     *      a String representing all aliases
-     */
-    private String concateNames( String[] aliases )
-    {
-        StringBuffer sb = new StringBuffer();
-
-        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/viewers/SchemaElementsViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsViewLabelProvider.java?view=diff&rev=520013&r1=520012&r2=520013
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsViewLabelProvider.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemaElementsViewLabelProvider.java
Mon Mar 19 09:55:46 2007
@@ -23,6 +23,7 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.view.ViewUtils;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
@@ -80,7 +81,7 @@
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_ALL_ALIASES
)
             {
-                label = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
+                label = ViewUtils.concateAliases( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_OID
)
             {
@@ -100,7 +101,7 @@
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_ALL_ALIASES
)
             {
-                label = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
+                label = ViewUtils.concateAliases( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_OID
)
             {
@@ -134,7 +135,8 @@
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_ALL_ALIASES
)
                 {
-                    secondaryLabel = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
+                    secondaryLabel = ViewUtils.concateAliases( ( ( AttributeTypeWrapper )
obj ).getMyAttributeType()
+                        .getNames() );
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_OID
)
                 {
@@ -149,7 +151,8 @@
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_ALL_ALIASES
)
                 {
-                    secondaryLabel = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
+                    secondaryLabel = ViewUtils.concateAliases( ( ( ObjectClassWrapper ) obj
).getMyObjectClass()
+                        .getNames() );
                 }
                 else if ( secondaryLabelValue == PluginConstants.PREFS_SCHEMA_ELEMENTS_VIEW_LABEL_OID
)
                 {
@@ -169,37 +172,15 @@
     }
 
 
-    /**
-     * Concatenates all aliases in a String format
-     *
-     * @param aliases
-     *      the aliases to concatenate
-     * @return
-     *      a String representing all aliases
-     */
-    private String concateNames( String[] aliases )
-    {
-        StringBuffer sb = new StringBuffer();
-
-        sb.append( aliases[0] );
-
-        for ( int i = 1; i < aliases.length; i++ )
-        {
-            sb.append( ", " );
-            sb.append( aliases[i] );
-        }
-
-        return sb.toString();
-    }
-
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
      */
     public Image getImage( Object obj )
     {
         if ( obj instanceof ITreeNode )
+        {
             return ( ( ITreeNode ) obj ).getImage();
+        }
 
         // Default
         return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK
);

Modified: directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java?view=diff&rev=520013&r1=520012&r2=520013
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-schemas-plugin/src/main/java/org/apache/directory/ldapstudio/schemas/view/viewers/SchemasViewLabelProvider.java
Mon Mar 19 09:55:46 2007
@@ -23,6 +23,7 @@
 
 import org.apache.directory.ldapstudio.schemas.Activator;
 import org.apache.directory.ldapstudio.schemas.PluginConstants;
+import org.apache.directory.ldapstudio.schemas.view.ViewUtils;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.AttributeTypeWrapper;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ITreeNode;
 import org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.ObjectClassWrapper;
@@ -74,7 +75,7 @@
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_ALL_ALIASES
)
             {
-                label = concateNames( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
+                label = ViewUtils.concateAliases( ( ( AttributeTypeWrapper ) obj ).getMyAttributeType().getNames()
);
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_OID )
             {
@@ -94,7 +95,7 @@
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_ALL_ALIASES
)
             {
-                label = concateNames( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
+                label = ViewUtils.concateAliases( ( ( ObjectClassWrapper ) obj ).getMyObjectClass().getNames()
);
             }
             else if ( labelValue == PluginConstants.PREFS_SCHEMAS_VIEW_LABEL_OID )
             {
@@ -138,29 +139,5 @@
 
         // Default
         return PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_OBJS_WARN_TSK
);
-    }
-
-
-    /**
-     * Concatenates all aliases in a String format
-     *
-     * @param aliases
-     *      the aliases to concatenate
-     * @return
-     *      a String representing all aliases
-     */
-    private String concateNames( String[] aliases )
-    {
-        StringBuffer sb = new StringBuffer();
-
-        sb.append( aliases[0] );
-
-        for ( int i = 1; i < aliases.length; i++ )
-        {
-            sb.append( ", " );
-            sb.append( aliases[i] );
-        }
-
-        return sb.toString();
     }
 }



Mime
View raw message