Package org.apache.sling.ide.eclipse.ui.nav.model

Examples of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode


   
    @Override
    public IStatus validateDrop(Object target, int operation,
            TransferData transferType) {
        if (target instanceof JcrNode) {
            JcrNode jcrNode = (JcrNode)target;
            IStatus result = jcrNode.validateDrop(operation, transferType);
            if (!result.isOK()) {
                // check for details to be shown in the status bar
                final String message = result.getMessage();
                if (message!=null && message.trim().length()>0) {
                    StatusLineUtils.setErrorMessage(2000, message);
View Full Code Here


        }
        if (!(aTarget instanceof JcrNode)) {
            StatusLineUtils.setErrorMessage(5000, "Cannot drop on this type of element");
            return Status.CANCEL_STATUS;
        }
        JcrNode node = (JcrNode)aTarget;
        if (LocalSelectionTransfer.getTransfer().isSupportedType(aDropAdapter.getCurrentTransfer())) {
            try {
                IStatus status = node.handleDrop(aDropTargetEvent.data, aDropTargetEvent.detail);
                if (!status.isOK()) {
                    final String message = status.getMessage();
                    if (message!=null && message.trim().length()>0) {
                        StatusLineUtils.setErrorMessage(5000, message);
                    }
                }
                return status;
            } catch(Exception e) {
                Activator.getDefault().getPluginLogger().error("Error handling drop: "+e, e);
                StatusLineUtils.setErrorMessage(5000, "Could not drop due to: "+e);
                return Status.CANCEL_STATUS;
            }
        } else if (FileTransfer.getInstance().isSupportedType(aDropAdapter.getCurrentTransfer())) {
            final IContainer targetContainer = node.getDropContainer();
            if (targetContainer == null)
                return Status.CANCEL_STATUS;

            getShell().forceActive();
            final Object data= FileTransfer.getInstance().nativeToJava(aDropAdapter.getCurrentTransfer());
View Full Code Here

  @Override
  public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof IProject) {
      return projectGetChildren((IProject)parentElement);
    } else if (parentElement instanceof JcrNode) {
      JcrNode node = (JcrNode)parentElement;
      return node.getChildren(true);
    } else {
      return null;
    }
  }
View Full Code Here

      return null;
    } else if (element instanceof SyncDir) {
      SyncDir syncDir = (SyncDir) element;
      return syncDir.getFolder().getProject();
    }
    JcrNode node = (JcrNode) element;
    return node.getParent();
  }
View Full Code Here

  @Override
  public boolean hasChildren(Object element) {
    if (element instanceof IProject) {
      return projectHasChildren((IProject)element);
    } else if (element instanceof JcrNode) {
      JcrNode jcrNode = (JcrNode) element;
      return jcrNode.hasChildren();
    }
    return false;
  }
View Full Code Here

    }

    void handleNewRowUpdate(NewRow newRow) {
        if (newRow.isComplete()) {
            tableViewer.remove(newRow);
            final JcrNode jcrNode = (JcrNode)tableViewer.getInput();
            final Integer type = newRow.getType();
            String encodeValueAsString = PropertyTypeSupport.encodeValueAsString(newRow.getValue(), type);
            if (type!=PropertyType.STRING && type!=PropertyType.NAME) {
                encodeValueAsString = "{"+PropertyType.nameFromValue(type)+"}"+encodeValueAsString;
            }
            final String propertyName = String.valueOf(newRow.getName());
            jcrNode.addProperty(propertyName, encodeValueAsString);
            view.refreshContent();
        } else {
            tableViewer.update(newRow, null);
        }
    }
View Full Code Here

            return true;
        }
       
        public Object getValue() {
            IPropertyDescriptor pd = (IPropertyDescriptor) element;
            JcrNode jcrNode = getNode();
            Map.Entry me = (Entry) pd.getId();
           
            switch(columnId) {
            case NAME: {
                return String.valueOf(me.getKey());
View Full Code Here

            if (getValue().equals(value)) {
                // then ignore this
                return;
            }
            JcrTextPropertyDescriptor pd = (JcrTextPropertyDescriptor) element;
            JcrNode jcrNode = getNode();
            Map.Entry me = (Entry) pd.getId();
           
            switch(columnId) {
            case NAME: {
                final String oldKey = String.valueOf(getValue());
                final String newKey = String.valueOf(value);
                pd.setNewPropertyName(newKey);
                Map<String, String> pseudoMap = new HashMap<String, String>();
                final String propertyValue = jcrNode.getProperties().getValue(oldKey);
                pseudoMap.put(newKey, propertyValue);
                final Entry<String, String> mapEntry = pseudoMap.entrySet().iterator().next();
                element = new TextPropertyDescriptor(mapEntry, propertyValue);
                jcrNode.renameProperty(oldKey, newKey);
                break;
            }
            case TYPE: {
                int propertyType = PropertyTypeSupport.propertyTypeOfIndex((Integer)value);
                jcrNode.changePropertyType(String.valueOf(me.getKey()), propertyType);
                break;
            }
            case VALUE: {
                try{
                    final JcrProperty property = getNode().getProperty(getPropertyName());
                    final int propertyType = property.getType();
                    String encodedValue;
                    if (property.isMultiple()) {
                        Object[] values = (Object[])value;
                        encodedValue = "";
                        for (int i = 0; i < values.length; i++) {
                            Object aValue = values[i];
                            String aValueAsString = PropertyTypeSupport.encodeValueAsString(aValue, propertyType);
                            if (i==0) {
                                encodedValue = aValueAsString;
                            } else {
                                encodedValue = encodedValue+","+aValueAsString;
                            }
                        }
                        encodedValue = "["+encodedValue+"]";
                    } else {
                        encodedValue = PropertyTypeSupport.encodeValueAsString(value, propertyType);
                    }
                    if (propertyType!=PropertyType.STRING && propertyType!=PropertyType.NAME) {
                        encodedValue = "{"+PropertyType.nameFromValue(propertyType)+"}"+encodedValue;
                    }
                    jcrNode.setPropertyValue(me.getKey(), encodedValue);
                } catch(Exception e) {
                    // emergency fallback
                    jcrNode.setPropertyValue(me.getKey(), String.valueOf(value));
                }
                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();
View Full Code Here

  }

  @Override
  public Image getImage(Object element) {
    if (element instanceof JcrNode) {
      JcrNode jcrNode = (JcrNode)element;
      return jcrNode.getImage();
    } else {
      // fallback to default
      return null;
    }
  }
View Full Code Here

  }

  @Override
  public String getText(Object element) {
    if (element instanceof JcrNode) {
      JcrNode jcrNode = (JcrNode)element;
      return jcrNode.getLabel();
    } else {
      // fallback to the default
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.sling.ide.eclipse.ui.nav.model.JcrNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.