directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1677535 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays: ModuleWrapper.java ModuleWrapperLabelProvider.java ModuleWrapperViewerSorter.java
Date Mon, 04 May 2015 07:28:00 GMT
Author: elecharny
Date: Mon May  4 07:28:00 2015
New Revision: 1677535

URL: http://svn.apache.org/r1677535
Log:
Added the classes used to expose the Overlay modules

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java?rev=1677535&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapper.java
Mon May  4 07:28:00 2015
@@ -0,0 +1,218 @@
+/*
+ *  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.studio.openldap.config.editor.overlays;
+
+
+
+/**
+ * This class implements a Module wrapper used in the 'Overlays' page UI. A Module
+ * has a name, a path and an order. We also have an additional index, which is
+ * the ModuleList index (this is necessary as two modules might have the same name
+ * but for a different path). 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModuleWrapper
+{
+    /** The moduleList's name */
+    private String moduleListName;
+    
+    /** The wrapped  moduleList index : we may have more than one moduleList */
+    private int moduleListIndex;
+    
+    /** The wrapped Module name */
+    private String moduleName;
+    
+    /** The wrapped module path */
+    private String path;
+    
+    /** The wrapped module order : we may have many modules for a given path*/
+    private int order;
+
+
+    /**
+     * Creates a new instance of ModuleWrapper.
+     */
+    public ModuleWrapper()
+    {
+    }
+
+
+    /**
+     * Creates a new instance of ModuleWrapper.
+     *
+     * @param moduleListName The ModuleList's name
+     * @param moduleListIndex the module's index
+     * @param module the wrapped module
+     * @param path the module's path
+     * @param order the module's order
+     */
+    public ModuleWrapper( String moduleListName, int moduleListIndex, String module, String
path, int order )
+    {
+        this.moduleListName = moduleListName;
+        this.moduleName = module;
+        this.path = path;
+        this.moduleListIndex = moduleListIndex;
+        this.order = order;
+    }
+
+
+    /**
+     * @return the moduleListName
+     */
+    public String getModuleListName()
+    {
+        return moduleListName;
+    }
+
+
+    /**
+     * Gets the moduleList's index
+     *
+     * @return the moduleList's index
+     */
+    public int getModuleListIndex()
+    {
+        return moduleListIndex;
+    }
+
+
+    /**
+     * Gets the wrapped module's name
+     *
+     * @return the wrapped module's name
+     */
+    public String getModuleName()
+    {
+        return moduleName;
+    }
+
+
+    /**
+     * Gets the wrapped path
+     *
+     * @return the wrapped path
+     */
+    public String getPath()
+    {
+        return path;
+    }
+
+
+    /**
+     * Gets the wrapped order
+     *
+     * @return the wrapped order
+     */
+    public int getOrder()
+    {
+        return order;
+    }
+
+
+    /**
+     * Sets the wrapped module's name.
+     *
+     * @param moduleName the wrapped module's name
+     */
+    public void setModuleName( String moduleName )
+    {
+        this.moduleName = moduleName;
+    }
+
+
+    /**
+     * Sets the moduleList's index.
+     *
+     * @param moduleListIndex the moduleList's index
+     */
+    public void setModuleIndex( int moduleListIndex )
+    {
+        this.moduleListIndex = moduleListIndex;
+    }
+
+
+    /**
+     * Sets the wrapped path.
+     *
+     * @param path the wrapped path
+     */
+    public void setPath( String path )
+    {
+        this.path = path;
+    }
+
+
+    /**
+     * @param moduleListName the moduleListName to set
+     */
+    public void setModuleListName( String moduleListName )
+    {
+        this.moduleListName = moduleListName;
+    }
+
+
+    /**
+     * Sets the wrapped order.
+     *
+     * @param moduleListIndex the wrapped order
+     */
+    public void setOrder( int order )
+    {
+        this.order = order;
+    }
+
+    
+    public String getModulePathName()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        if ( path != null )
+        {
+            sb.append( path ).append( "/" );
+        }
+        
+        sb.append( "{" ).append( order ).append( '}' ).append( moduleName );
+        
+        return sb.toString();
+    }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( moduleListName ).append( '{').append(  moduleListIndex ).append( '}' );
+
+        sb.append( ':' );
+        
+        if ( path != null )
+        {
+            sb.append( path ).append( "/" );
+        }
+        
+        sb.append( "{" ).append( order ).append( '}' ).append( moduleName );
+        
+        return sb.toString();
+    }
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java?rev=1677535&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperLabelProvider.java
Mon May  4 07:28:00 2015
@@ -0,0 +1,61 @@
+/*
+ *  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.studio.openldap.config.editor.overlays;
+
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginConstants;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This class defines a label provider for a module wrapper viewer.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModuleWrapperLabelProvider extends LabelProvider
+{
+    /**
+     * Construct the label for a ModuleList. It's the type, followed by the suffixDN.
+     */
+    public String getText( Object element )
+    {
+        if ( element instanceof ModuleWrapper )
+        {
+            return ( ( ModuleWrapper ) element ).getModulePathName();
+        }
+
+        return super.getText( element );
+    };
+
+
+    /**
+     * Get the ModuleList image, if it's a ModuleList
+     */
+    public Image getImage( Object element )
+    {
+        if ( element instanceof ModuleWrapper )
+        {
+            return OpenLdapConfigurationPlugin.getDefault().getImage(
+                OpenLdapConfigurationPluginConstants.IMG_DATABASE );
+        }
+
+        return super.getImage( element );
+    };
+}

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java?rev=1677535&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/overlays/ModuleWrapperViewerSorter.java
Mon May  4 07:28:00 2015
@@ -0,0 +1,86 @@
+/*
+ *  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.studio.openldap.config.editor.overlays;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * This class defines a sorter for a ModuleList wrapper viewer.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModuleWrapperViewerSorter extends ViewerSorter
+{
+    public int compare( Viewer viewer, Object e1, Object e2 )
+    {
+        if ( ( e1 != null ) && ( e2 != null ) && ( e1 instanceof ModuleWrapper
)
+            && ( e2 instanceof ModuleWrapper ) )
+        {
+            ModuleWrapper module1 = (ModuleWrapper)e1;
+            ModuleWrapper module2 = (ModuleWrapper)e2;
+            
+            if ( e1 == e2 )
+            {
+                // Short circuit...
+                return 0;
+            }
+            
+            // First, compare the moduleList
+            int comp = module1.getModuleListName().compareToIgnoreCase( module2.getModuleListName()
);
+            
+            if ( comp == 0 )
+            {
+                // Same ModuleList. Check the index
+                if ( module1.getModuleListIndex() == module2.getModuleListIndex() )
+                {
+                    // Same index : check the modules' order
+                    if ( module1.getOrder() > module2.getOrder() )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return -1;
+                    }
+                }
+                else
+                {
+                    // We can get out
+                    if ( module1.getModuleListIndex() > module2.getModuleListIndex() )
+                    {
+                        return 1;
+                    }
+                    else
+                    {
+                        return -1;
+                    }
+                }
+            }
+            else
+            {
+                // The are different, we can get out
+                return comp;
+            }
+        }
+
+        return super.compare( viewer, e1, e2 );
+    }
+}



Mime
View raw message