Search in sources :

Example 1 with JcrProperty

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty in project sling by apache.

the class MVNCellEditor method openDialogBox.

@Override
protected Object openDialogBox(Control cellEditorWindow) {
    final JcrProperty property = node.getProperty(propertyName);
    final MVPEditor mvpEditor = new MVPEditor(cellEditorWindow.getShell(), property);
    if (mvpEditor.open() == IStatus.OK) {
        return mvpEditor.getLines();
    } else {
        return null;
    }
}
Also used : JcrProperty(org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty)

Example 2 with JcrProperty

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty in project sling by apache.

the class JcrCellLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    int index = cell.getColumnIndex();
    if (!isNewRow(cell)) {
        if (canEdit(cell)) {
            cell.setForeground(normalColor);
        } else {
            cell.setForeground(greyColor);
        }
    }
    if (index == 0) {
        updateName(cell);
        return;
    } else if (index == 1) {
        final Object element = cell.getElement();
        if (element instanceof NewRow) {
            NewRow newRow = (NewRow) element;
            int propertyType = newRow.getType();
            String type = PropertyType.nameFromValue(propertyType);
            cell.setText(type);
        } else if (element instanceof IPropertyDescriptor) {
            IPropertyDescriptor pd = (IPropertyDescriptor) element;
            JcrNode jcrNode = (JcrNode) viewer.getInput();
            Map.Entry me = (Entry) pd.getId();
            final String propertyName = String.valueOf(me.getKey());
            int propertyType = jcrNode.getPropertyType(propertyName);
            if (propertyType <= -1 || propertyType == PropertyType.UNDEFINED) {
                cell.setText("");
            } else {
                final JcrProperty property = jcrNode.getProperty(propertyName);
                String type = PropertyType.nameFromValue(propertyType);
                if (property != null && property.isMultiple()) {
                    type = type + "[]";
                }
                cell.setText(type);
            }
        } else {
            cell.setText("");
        }
        return;
    } else if (index == 2) {
        updateValue(cell);
        return;
    } else {
        final Object element = cell.getElement();
        if (element instanceof NewRow) {
            NewRow newRow = (NewRow) element;
            cell.setText("");
        } else if (element instanceof IPropertyDescriptor) {
            IPropertyDescriptor pd = (IPropertyDescriptor) element;
            JcrNode jcrNode = (JcrNode) viewer.getInput();
            Map.Entry me = (Entry) pd.getId();
            PropertyDefinition prd = jcrNode.getPropertyDefinition(String.valueOf(me.getKey()));
            if (index == 3) {
                // protected
                if (prd != null) {
                    cell.setText(String.valueOf(prd.isProtected()));
                } else {
                    cell.setText("false");
                }
            } else if (index == 4) {
                // mandatory
                if (prd != null) {
                    cell.setText(String.valueOf(prd.isMandatory()));
                } else {
                    cell.setText("false");
                }
            } else if (index == 5) {
                // multiple
                if (prd != null) {
                    cell.setText(String.valueOf(prd.isMultiple()));
                } else {
                    cell.setText(String.valueOf(jcrNode.getProperty(String.valueOf(me.getKey())).isMultiple()));
                }
            } else if (index == 6) {
                // auto creatd
                if (prd != null) {
                    cell.setText(String.valueOf(prd.isAutoCreated()));
                } else {
                    cell.setText("false");
                }
            } else {
                cell.setText("n/a");
                return;
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) Entry(java.util.Map.Entry) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) JcrProperty(org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) Map(java.util.Map) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition)

Example 3 with JcrProperty

use of org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty in project sling by apache.

the class DateTimeCellEditor method openDialogBox.

@Override
protected Object openDialogBox(Control cellEditorWindow) {
    final JcrProperty property = node.getProperty(propertyName);
    final DateTimeEditor dtEditor = new DateTimeEditor(cellEditorWindow.getShell(), property);
    if (dtEditor.open() == IStatus.OK) {
        return dtEditor.getDate();
    } else {
        return null;
    }
}
Also used : JcrProperty(org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty)

Aggregations

JcrProperty (org.apache.sling.ide.eclipse.ui.nav.model.JcrProperty)3 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)1 JcrNode (org.apache.sling.ide.eclipse.ui.nav.model.JcrNode)1 IPropertyDescriptor (org.eclipse.ui.views.properties.IPropertyDescriptor)1