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);
}
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations