directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1687686 - in /directory/studio/trunk/plugins: common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/ openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/
Date Fri, 26 Jun 2015 07:27:24 GMT
Author: elecharny
Date: Fri Jun 26 07:27:24 2015
New Revision: 1687686

URL: http://svn.apache.org/r1687686
Log:
o Added the OrderedElement interface which must be implemented by any element being added
into an ordered table
o Implemented the prefix increase/decrease in the Up and Down method
o Made the OrderedStringValueWrapper implementing the OrderedElement interface

Added:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/OrderedElement.java
Modified:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueWrapper.java

Added: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/OrderedElement.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/OrderedElement.java?rev=1687686&view=auto
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/OrderedElement.java
(added)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/OrderedElement.java
Fri Jun 26 07:27:24 2015
@@ -0,0 +1,39 @@
+/*
+ *  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.common.ui.widgets;
+
+/**
+ * An interface to be implemented by objects stored into an Ordered table
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface OrderedElement
+{
+    /**
+     * Move an element up in the list of elements, decreasing its prefix
+     */
+    void incrementPrefix();
+    
+    
+    /**
+     * Move an element down in the list of elements, increasing its prefix
+     */
+    void decrementPrefix();
+}

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java?rev=1687686&r1=1687685&r2=1687686&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
(original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/TableWidget.java
Fri Jun 26 07:27:24 2015
@@ -762,8 +762,15 @@ public class TableWidget<E> extends Abst
             // The selected element
             E selectedElement = (E)selection.getFirstElement();
             
+            // Decrease the prefix
+            ((OrderedElement)selectedElement).decrementPrefix();
+            
             // Just swap the elements which is just before with the selected one
             E previousElement = getElements().get( selectionLine - 1 );
+
+            // Increase the prefix
+            ((OrderedElement)previousElement).incrementPrefix();
+            
             elements.remove( selectionLine - 1 );
             elements.add( selectionLine, previousElement );
             
@@ -791,13 +798,20 @@ public class TableWidget<E> extends Abst
             
             // The selected element
             E selectedElement = (E)selection.getFirstElement();
+
+            // Increase the prefix
+            ((OrderedElement)selectedElement).incrementPrefix();
             
             // Just swap the elements which is just after with the selected one
             E previousElement = getElements().get( selectionLine + 1 );
+
+            // Decrease the prefix
+            ((OrderedElement)previousElement).decrementPrefix();
+
             elements.remove( selectionLine + 1 );
             elements.add( selectionLine, previousElement );
             
-            // refresh teh table now
+            // refresh the table now
             elementTableViewer.refresh();
             elementTableViewer.setSelection( new StructuredSelection( selectedElement ) );
 

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueWrapper.java?rev=1687686&r1=1687685&r2=1687686&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedStringValueWrapper.java
Fri Jun 26 07:27:24 2015
@@ -20,13 +20,14 @@
 package org.apache.directory.studio.openldap.config.editor.wrappers;
 
 import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.common.ui.widgets.OrderedElement;
 
 /**
  * A wrapper for an ordered String value. The value is prefixed by "{n}" where n is an integer.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class OrderedStringValueWrapper implements Cloneable, Comparable<OrderedStringValueWrapper>
+public class OrderedStringValueWrapper implements Cloneable, Comparable<OrderedStringValueWrapper>,
OrderedElement
 {
     /** The value */
     private String value;
@@ -88,6 +89,24 @@ public class OrderedStringValueWrapper i
     {
         return prefix;
     }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void decrementPrefix()
+    {
+        prefix--;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void incrementPrefix()
+    {
+        prefix++;
+    }
 
     
     /**



Mime
View raw message