You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2014/06/13 09:33:12 UTC

svn commit: r1602333 - in /sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views: JcrCellLabelProvider.java JcrEditingSupport.java JcrPropertiesView.java

Author: stefanegli
Date: Fri Jun 13 07:33:11 2014
New Revision: 1602333

URL: http://svn.apache.org/r1602333
Log:
SLING-3666 : supporting changing of the multiple mode in the jcr properties view - plus resized those columns to have header properly visible - note that for new rows the flag is not yet changeable until the value is added to the underlying .content.xml (atm)

Modified:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrCellLabelProvider.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrEditingSupport.java
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrPropertiesView.java

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrCellLabelProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrCellLabelProvider.java?rev=1602333&r1=1602332&r2=1602333&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrCellLabelProvider.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrCellLabelProvider.java Fri Jun 13 07:33:11 2014
@@ -153,14 +153,17 @@ public class JcrCellLabelProvider extend
     }
 
     private boolean canEdit(ViewerCell cell) {
-        if (cell.getColumnIndex()>2) {
-            return false;
-        }
         Object element = cell.getElement();
         if (element instanceof NewRow) {
             // can edit everything of a newrow (other than type properties)
+            if (cell.getColumnIndex()>2) {
+                return false;
+            }
             return true;
         } else if (element instanceof IPropertyDescriptor){
+            if (cell.getColumnIndex()>2 && cell.getColumnIndex()!=5) {
+                return false;
+            }
             IPropertyDescriptor pd = (IPropertyDescriptor)element;
             JcrNode jcrNode = (JcrNode)viewer.getInput();
             Map.Entry me = (Entry) pd.getId();

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrEditingSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrEditingSupport.java?rev=1602333&r1=1602332&r2=1602333&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrEditingSupport.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrEditingSupport.java Fri Jun 13 07:33:11 2014
@@ -53,7 +53,7 @@ import org.eclipse.ui.views.properties.T
 public class JcrEditingSupport extends EditingSupport {
     
     static enum ColumnId {
-        NAME, TYPE, VALUE
+        NAME, TYPE, VALUE, MULTIPLE
     }
 
     private final ColumnId columnId;
@@ -116,6 +116,10 @@ public class JcrEditingSupport extends E
                 }
                 return String.valueOf(me.getValue());
             }
+            case MULTIPLE: {
+                boolean isMultiple = getNode().getProperty(getPropertyName()).isMultiple();
+                return isMultiple ? 1 : 0;
+            }
             default: {
                 throw new IllegalStateException("Unknown columnId: "+columnId);
             }
@@ -186,6 +190,45 @@ public class JcrEditingSupport extends E
                 }
                 break;
             }
+            case MULTIPLE: {
+                if (!(value instanceof Integer)) {
+                    // value must be an integer
+                    return;
+                }
+                final Integer newIsMultipleValue = (Integer) value;
+                final boolean newIsMultiple = newIsMultipleValue==1;
+                final JcrProperty property = getNode().getProperty(getPropertyName());
+                final boolean oldIsMultiple = property.isMultiple();
+                if (newIsMultiple==oldIsMultiple) {
+                    // then nothing is to be done
+                    return;
+                }
+                final String oldPropertyValue = getNode().getProperties().getValue(getPropertyName());
+                // split {type} prefix from value
+                int cPos = oldPropertyValue.indexOf("}");
+                final String prefix;
+                final String rawValue;
+                if (cPos==-1) {
+                    prefix = "";
+                    rawValue = oldPropertyValue;
+                } else {
+                    prefix = oldPropertyValue.substring(0, cPos+1);
+                    rawValue = oldPropertyValue.substring(cPos+1);
+                }
+                String newValue;
+                if (newIsMultiple) {
+                    newValue = prefix + "[" + rawValue + "]";
+                } else {
+                    newValue = rawValue.substring(1, rawValue.length()-1);
+                    int commaPos = newValue.indexOf(",");
+                    if (commaPos!=-1) {
+                        newValue = newValue.substring(0, commaPos);
+                    }
+                    newValue = prefix + newValue;
+                }
+                jcrNode.setPropertyValue(getPropertyName(), newValue);
+                break;
+            }
             }
 
             view.refreshContent();
@@ -253,6 +296,9 @@ public class JcrEditingSupport extends E
                     //TODO: otherwise hardcode to STRING
                     return PropertyTypeSupport.indexOfPropertyType(PropertyType.STRING);
                 }
+            } else if (columnId==ColumnId.MULTIPLE) {
+                //TODO
+                return 0;
             } else {
                 return null;
             }
@@ -287,6 +333,9 @@ public class JcrEditingSupport extends E
             } else if (columnId==ColumnId.TYPE) {
                 int propertyType = PropertyTypeSupport.propertyTypeOfIndex((Integer)value);
                 newRow.setType(propertyType);
+            } else if (columnId==ColumnId.MULTIPLE) {
+                // do nothing at the moment
+                //TODO
             } else {
                 // otherwise non-editable
                 return;
@@ -416,6 +465,12 @@ public class JcrEditingSupport extends E
             }
             return editor;
         }
+        case MULTIPLE: {
+            if (element instanceof NewRow) {
+                return null;
+            }
+            return new ComboBoxCellEditor(tableViewer.getTable(), new String[] {"false", "true"}, SWT.READ_ONLY);
+        }
         default: {
             throw new IllegalStateException("Unknown columnId: "+columnId);
         }

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrPropertiesView.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrPropertiesView.java?rev=1602333&r1=1602332&r2=1602333&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrPropertiesView.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/views/JcrPropertiesView.java Fri Jun 13 07:33:11 2014
@@ -236,28 +236,28 @@ public class JcrPropertiesView extends V
         column3.getColumn().setResizable(true);
         column3.getColumn().setWidth(300);
         column3.setLabelProvider(clp);
-        tableLayout.setColumnData(column3.getColumn(), new ColumnWeightData(5, 50));
+        tableLayout.setColumnData(column3.getColumn(), new ColumnWeightData(5, 57));
 
         final TableViewerColumn column4 = new TableViewerColumn(viewer, SWT.NONE);
         column4.getColumn().setText("Mandatory");
         column4.getColumn().setResizable(true);
         column4.getColumn().setWidth(300);
         column4.setLabelProvider(clp);
-        tableLayout.setColumnData(column4.getColumn(), new ColumnWeightData(5, 50));
+        tableLayout.setColumnData(column4.getColumn(), new ColumnWeightData(5, 62));
 
         final TableViewerColumn column5 = new TableViewerColumn(viewer, SWT.NONE);
         column5.getColumn().setText("Multiple");
         column5.getColumn().setResizable(true);
         column5.getColumn().setWidth(300);
         column5.setLabelProvider(clp);
-        tableLayout.setColumnData(column5.getColumn(), new ColumnWeightData(5, 50));
+        tableLayout.setColumnData(column5.getColumn(), new ColumnWeightData(5, 82));
 
         final TableViewerColumn column6 = new TableViewerColumn(viewer, SWT.NONE);
         column6.getColumn().setText("Auto Created");
         column6.getColumn().setResizable(true);
         column6.getColumn().setWidth(300);
         column6.setLabelProvider(clp);
-        tableLayout.setColumnData(column6.getColumn(), new ColumnWeightData(5, 50));
+        tableLayout.setColumnData(column6.getColumn(), new ColumnWeightData(5, 77));
 
         column0.setLabelProvider(clp);
         column0.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.NAME));
@@ -267,6 +267,8 @@ public class JcrPropertiesView extends V
 
         column2.setLabelProvider(clp);
 		column2.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.VALUE));
+	
+        column5.setEditingSupport(new JcrEditingSupport(this, viewer, ColumnId.MULTIPLE));
 		
 		// Create the help context id for the viewer's control
 		PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.apache.sling.ide.eclipse-ui.viewer");
@@ -502,8 +504,12 @@ public class JcrPropertiesView extends V
                                 column = 0;
                             } else if (lastEditedColumnId==ColumnId.TYPE) {
                                 column = 1;
-                            } else {
+                            } else if (lastEditedColumnId==ColumnId.VALUE) {
                                 column = 2;
+                            } else if (lastEditedColumnId==ColumnId.MULTIPLE) {
+                                column = 5;
+                            } else {
+                                throw new IllegalStateException("Unknown columnId="+lastEditedColumnId);
                             }
                             Display.getDefault().asyncExec(new Runnable() {