Search in sources :

Example 36 with EJDataRecord

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

the class EJRWTPieChartRecordBlockRenderer method enterInsert.

@Override
public void enterInsert(EJDataRecord record) {
    if (_block.getInsertScreenRenderer() == null) {
        EJMessage message = new EJMessage("Please define an Insert Screen Renderer for this form before an insert operation can be performed.");
        _block.getForm().getMessenger().handleMessage(message);
    } else {
        EJDataRecord focusedRecord = getFocusedRecord();
        if (focusedRecord != null) {
            final String pid = _rendererProp.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.PARENT_ITEM);
            final String rid = _rendererProp.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.RELATION_ITEM);
            record.setValue(rid, focusedRecord.getValue(pid));
        }
        _block.getInsertScreenRenderer().open(record);
    }
}
Also used : EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJMessage(org.entirej.framework.core.EJMessage)

Example 37 with EJDataRecord

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

the class EJRWTMultiRecordBlockRenderer method recordDeleted.

@Override
public void recordDeleted(int dataBlockRecordNumber) {
    EJDataRecord recordAt = getRecordAt(dataBlockRecordNumber > 1 ? dataBlockRecordNumber - 2 : 0);
    if (recordAt == null) {
        recordAt = getLastRecord();
    }
    if (_tableViewer != null && !_tableViewer.getTable().isDisposed()) {
        clearFilter();
        _tableViewer.setInput(new Object());
        applyFileter();
    }
    if (recordAt != null) {
        recordSelected(recordAt);
    }
}
Also used : EJDataRecord(org.entirej.framework.core.data.EJDataRecord)

Example 38 with EJDataRecord

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

the class EJRWTMultiRecordBlockRenderer method getFocusedRecord.

@Override
public EJDataRecord getFocusedRecord() {
    EJDataRecord _focusedRecord = null;
    if (_tableViewer != null && !_tableViewer.getTable().isDisposed()) {
        ISelection selection = _tableViewer.getSelection();
        if (selection instanceof IStructuredSelection) {
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object firstElement = structuredSelection.getFirstElement();
            if (firstElement instanceof EJDataRecord) {
                _focusedRecord = (EJDataRecord) firstElement;
            }
        }
    }
    return _focusedRecord;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EJDataRecord(org.entirej.framework.core.data.EJDataRecord)

Example 39 with EJDataRecord

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

the class EJRWTDateTimeItemRenderer method createColumnLabelProvider.

@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
    final DateFormat 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) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Color(org.eclipse.swt.graphics.Color) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJCoreVisualAttributeProperties(org.entirej.framework.core.properties.EJCoreVisualAttributeProperties)

Example 40 with EJDataRecord

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

the class EJRWTListItemRenderer method loadListBoxValues.

private void loadListBoxValues() {
    // Initialise both the field and the values.
    _lovInitialied = true;
    _listValues.clear();
    _listKays.clear();
    String lovDefName = _rendererProps.getStringProperty(EJRWTListBoxRendererDefinitionProperties.LOV_DEFINITION_NAME);
    if (lovDefName == null || lovDefName.trim().length() == 0) {
        return;
    }
    String defName = lovDefName;
    String defItemName = "";
    if (lovDefName.indexOf('.') != -1) {
        defName = lovDefName.substring(0, lovDefName.indexOf('.'));
        defItemName = lovDefName.substring(lovDefName.indexOf('.') + 1);
    } else {
        EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ListBox renderer properties on item: " + _itemProperties.getName());
        _item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
        return;
    }
    if (_item.getBlock().getProperties().isReferenceBlock()) {
        defName = String.format("%s.%s", _item.getBlock().getProperties().getName(), defName);
    }
    EJLovDefinitionProperties lovDef = _item.getForm().getProperties().getLovDefinitionProperties(defName);
    if (lovDef == null) {
        return;
    }
    EJLovController lovController = _item.getForm().getLovController(defName);
    if (lovController == null) {
        return;
    }
    try {
        lovController.executeQuery(new EJItemLovController(_item.getBlock().getBlockController().getFormController(), _item, ((EJCoreItemProperties) _itemProperties).getLovMappingPropertiesOnUpdate()));
        Collection<EJDataRecord> records = lovController.getRecords();
        for (EJDataRecord ejDataRecord : records) {
            if (!ejDataRecord.containsItem(defItemName)) {
                EJMessage message = new EJMessage("The item name '" + defItemName + "', does not exist within the lov definitions underlying block. Lov Definition: " + defName);
                _item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
                return;
            }
            ListBoxValue listValue = new ListBoxValue(ejDataRecord, defItemName);
            String itemValueAsString = listValue.getItemValueAsString();
            _listValues.put(itemValueAsString, listValue);
            _listKays.add(itemValueAsString);
        }
    } catch (Exception e) {
        _item.getForm().getFrameworkManager().getApplicationManager().getApplicationMessenger().handleException(e, true);
    }
}
Also used : EJLovDefinitionProperties(org.entirej.framework.core.properties.interfaces.EJLovDefinitionProperties) EJItemLovController(org.entirej.framework.core.data.controllers.EJItemLovController) EJCoreItemProperties(org.entirej.framework.core.properties.EJCoreItemProperties) EJLovController(org.entirej.framework.core.data.controllers.EJLovController) EJDataRecord(org.entirej.framework.core.data.EJDataRecord) EJMessage(org.entirej.framework.core.EJMessage) MalformedURLException(java.net.MalformedURLException)

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