Search in sources :

Example 6 with EJCoreVisualAttributeProperties

use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties 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 7 with EJCoreVisualAttributeProperties

use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties 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 8 with EJCoreVisualAttributeProperties

use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties 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)

Example 9 with EJCoreVisualAttributeProperties

use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties in project rap by entirej.

the class EJRWTButtonItemRenderer method createColumnLabelProvider.

@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
    final Image image;
    String pictureName = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.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) {
            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 10 with EJCoreVisualAttributeProperties

use of org.entirej.framework.core.properties.EJCoreVisualAttributeProperties in project rap by entirej.

the class EJRWTCheckBoxItemRenderer method createColumnLabelProvider.

@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, final EJScreenItemController controller) {
    EJItemProperties itemProperties = controller.getReferencedItemProperties();
    EJFrameworkExtensionProperties itemRendererProperties = itemProperties.getItemRendererProperties();
    final Object checkedValue = getValueAsObject(itemProperties.getDataTypeClass(), itemRendererProperties.getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.CHECKED_VALUE));
    final Object uncheckedValue = getValueAsObject(itemProperties.getDataTypeClass(), itemRendererProperties.getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.UNCHECKED_VALUE));
    final boolean otherValueMappingValue = EJRWTCheckBoxRendererDefinitionProperties.CHECKED.equals(itemRendererProperties.getStringProperty(EJRWTCheckBoxRendererDefinitionProperties.OTHER_VALUE_MAPPING));
    final boolean defaultState = EJRWTCheckBoxRendererDefinitionProperties.CHECKED.equals(otherValueMappingValue);
    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) {
            return "";
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof EJDataRecord) {
                EJDataRecord record = (EJDataRecord) element;
                Object value = record.getValue(item.getReferencedItemName());
                if (value != null) {
                    if (value.equals(checkedValue)) {
                        return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_SELECTED);
                    } else if (value.equals(uncheckedValue)) {
                        return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_UNSELECTED);
                    } else {
                        if (otherValueMappingValue) {
                            return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_SELECTED);
                        } else {
                            return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_UNSELECTED);
                        }
                    }
                } else {
                    if (defaultState) {
                        return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_SELECTED);
                    } else {
                        return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_UNSELECTED);
                    }
                }
            }
            return EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_CHECK_UNSELECTED);
        }
    };
    return provider;
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) EJFrameworkExtensionProperties(org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties) EJScreenItemProperties(org.entirej.framework.core.properties.interfaces.EJScreenItemProperties) Color(org.eclipse.swt.graphics.Color) EJItemProperties(org.entirej.framework.core.properties.interfaces.EJItemProperties) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Aggregations

EJCoreVisualAttributeProperties (org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)24 EJScreenItemProperties (org.entirej.framework.core.properties.interfaces.EJScreenItemProperties)16 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)15 EJDataRecord (org.entirej.framework.core.data.EJDataRecord)15 Color (org.eclipse.swt.graphics.Color)12 EJScreenItemController (org.entirej.framework.core.interfaces.EJScreenItemController)12 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)11 EJRWTAppItemRenderer (org.entirej.applicationframework.rwt.renderer.interfaces.EJRWTAppItemRenderer)8 EJCoreMainScreenItemProperties (org.entirej.framework.core.properties.EJCoreMainScreenItemProperties)8 JsonObject (org.eclipse.rap.json.JsonObject)7 EJManagedItemRendererWrapper (org.entirej.framework.core.renderers.EJManagedItemRendererWrapper)7 EJFrameworkExtensionPropertyList (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyList)6 EJFrameworkExtensionPropertyListEntry (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionPropertyListEntry)6 GridData (org.eclipse.swt.layout.GridData)5 EJRWTEntireJGridPane (org.entirej.applicationframework.rwt.layout.EJRWTEntireJGridPane)5 ArrayList (java.util.ArrayList)4 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 ToolBarManager (org.eclipse.jface.action.ToolBarManager)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4