Search in sources :

Example 16 with EJDataRecord

use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.

the class EJRWTDateTimeItemRenderer method getColumnSorter.

@Override
public EJRWTAbstractTableSorter getColumnSorter(final EJScreenItemProperties item, EJScreenItemController controller) {
    return new EJRWTAbstractTableSorter() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof EJDataRecord && e2 instanceof EJDataRecord) {
                EJDataRecord d1 = (EJDataRecord) e1;
                EJDataRecord d2 = (EJDataRecord) e2;
                if (d1 != null && d2 != null) {
                    Object value1 = d1.getValue(item.getReferencedItemName());
                    Object value2 = d2.getValue(item.getReferencedItemName());
                    if (value1 == null && value2 == null) {
                        return 0;
                    }
                    if (value1 == null && value2 != null) {
                        return -1;
                    }
                    if (value1 != null && value2 == null) {
                        return 1;
                    }
                    if (value1 instanceof Comparable) {
                        @SuppressWarnings("unchecked") Comparable<Object> comparable = (Comparable<Object>) value1;
                        return comparable.compareTo(value2);
                    }
                }
            }
            return 0;
        }
    };
}
Also used : Viewer(org.eclipse.jface.viewers.Viewer) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)

Example 17 with EJDataRecord

use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.

the class EJRWTDateItemRenderer method createColumnLabelProvider.

@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
    final MultiDateFormater format = createDateFormat(controller);
    ColumnLabelProvider provider = new ColumnLabelProvider() {

        @Override
        public Color getBackground(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(properties);
                if (background != null) {
                    return background;
                }
            }
            return super.getBackground(element);
        }

        @Override
        public Color getForeground(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(properties);
                if (foreground != null) {
                    return foreground;
                }
            }
            return super.getForeground(element);
        }

        private EJCoreVisualAttributeProperties getAttributes(final EJScreenItemProperties item, Object element) {
            EJCoreVisualAttributeProperties properties = null;
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                properties = record.getItem(item.getReferencedItemName()).getVisualAttribute();
            }
            if (properties == null) {
                properties = _visualAttributeProperties;
            }
            return properties;
        }

        @Override
        public Font getFont(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                return EJRWTVisualAttributeUtils.INSTANCE.getFont(properties, super.getFont(element));
            }
            return super.getFont(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                Object value = record.getValue(item.getReferencedItemName());
                if (value != null) {
                    return format.format(value);
                }
            }
            return "";
        }
    };
    return provider;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) Color(org.eclipse.swt.graphics.Color) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 18 with EJDataRecord

use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.

the class EJRWTDateItemRenderer method getColumnSorter.

@Override
public EJRWTAbstractTableSorter getColumnSorter(final EJScreenItemProperties item, EJScreenItemController controller) {
    return new EJRWTAbstractTableSorter() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof EJDataRecord && e2 instanceof EJDataRecord) {
                EJDataRecord d1 = (EJDataRecord) e1;
                EJDataRecord d2 = (EJDataRecord) e2;
                if (d1 != null && d2 != null) {
                    Object value1 = d1.getValue(item.getReferencedItemName());
                    Object value2 = d2.getValue(item.getReferencedItemName());
                    if (value1 == null && value2 == null) {
                        return 0;
                    }
                    if (value1 == null && value2 != null) {
                        return -1;
                    }
                    if (value1 != null && value2 == null) {
                        return 1;
                    }
                    if (value1 instanceof Comparable) {
                        @SuppressWarnings("unchecked") Comparable<Object> comparable = (Comparable<Object>) value1;
                        return comparable.compareTo(value2);
                    }
                }
            }
            return 0;
        }
    };
}
Also used : Viewer(org.eclipse.jface.viewers.Viewer) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJRWTAbstractTableSorter(org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)

Example 19 with EJDataRecord

use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.

the class EJRWTLabelItemRenderer method createColumnLabelProvider.

@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
    final Image image;
    String pictureName = _rendererProps.getStringProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_PICTURE);
    if (pictureName != null && pictureName.length() > 0) {
        image = EJRWTImageRetriever.get(pictureName);
    } else {
        image = null;
    }
    ColumnLabelProvider provider = new ColumnLabelProvider() {

        @Override
        public Image getImage(Object element) {
            return image;
        }

        @Override
        public Color getBackground(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(properties);
                if (background != null) {
                    return background;
                }
            }
            return super.getBackground(element);
        }

        @Override
        public Color getForeground(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(properties);
                if (foreground != null) {
                    return foreground;
                }
            }
            return super.getForeground(element);
        }

        private EJCoreVisualAttributeProperties getAttributes(final EJScreenItemProperties item, Object element) {
            EJCoreVisualAttributeProperties properties = null;
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                properties = record.getItem(item.getReferencedItemName()).getVisualAttribute();
            }
            if (properties == null) {
                properties = _visualAttributeProperties;
            }
            return properties;
        }

        @Override
        public Font getFont(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                return EJRWTVisualAttributeUtils.INSTANCE.getFont(properties, super.getFont(element));
            }
            return super.getFont(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                Object value = record.getValue(item.getReferencedItemName());
                if (value != null) {
                    return value.toString();
                }
            }
            String label = item.getLabel();
            return label != null ? label : "";
        }
    };
    return provider;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) Color(org.eclipse.swt.graphics.Color) Image(org.eclipse.swt.graphics.Image) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 20 with EJDataRecord

use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.

the class EJRWTNumberItemRenderer method createColumnLabelProvider.

@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
    NUMBER_TYPE numberType = getNumberType(controller);
    final DecimalFormat format = createFormatter(controller, numberType);
    ColumnLabelProvider provider = new ColumnLabelProvider() {

        @Override
        public Color getBackground(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(properties);
                if (background != null) {
                    return background;
                }
            }
            return super.getBackground(element);
        }

        @Override
        public Color getForeground(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(properties);
                if (foreground != null) {
                    return foreground;
                }
            }
            return super.getForeground(element);
        }

        private EJCoreVisualAttributeProperties getAttributes(final EJScreenItemProperties item, Object element) {
            EJCoreVisualAttributeProperties properties = null;
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                properties = record.getItem(item.getReferencedItemName()).getVisualAttribute();
            }
            if (properties == null) {
                properties = _visualAttributeProperties;
            }
            return properties;
        }

        @Override
        public Font getFont(Object element) {
            EJCoreVisualAttributeProperties properties = getAttributes(item, element);
            if (properties != null) {
                return EJRWTVisualAttributeUtils.INSTANCE.getFont(properties, super.getFont(element));
            }
            return super.getFont(element);
        }

        @Override
        public String getText(Object element) {
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                Object value = record.getValue(item.getReferencedItemName());
                if (value != null && value instanceof Number) {
                    return format.format(value);
                }
            }
            return "";
        }
    };
    return provider;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) DecimalFormat(java.text.DecimalFormat) Color(org.eclipse.swt.graphics.Color) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Aggregations

EJDataRecord (org.entirej.framework.core.data.EJDataRecord)52 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)18 EJScreenItemProperties (org.entirej.framework.core.properties.interfaces.EJScreenItemProperties)16 EJCoreVisualAttributeProperties (org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)15 Color (org.eclipse.swt.graphics.Color)12 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)12 Viewer (org.eclipse.jface.viewers.Viewer)11 EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)11 ArrayList (java.util.ArrayList)10 EJCoreMainScreenItemProperties (org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)10 EJMessage (org.entirej.framework.core.EJMessage)9 EJRWTAbstractTableSorter (org.entirej.applicationframework.rwt.table.EJRWTAbstractTableSorter)8 EJBlockProperties (org.entirej.framework.core.properties.interfaces.EJBlockProperties)8 JsonObject (org.eclipse.rap.json.JsonObject)7 GridData (org.eclipse.swt.layout.GridData)7 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)7 EJItemGroupProperties (org.entirej.framework.core.properties.interfaces.EJItemGroupProperties)7 HashMap (java.util.HashMap)6 ISelection (org.eclipse.jface.viewers.ISelection)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6