use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.
the class EJRWTListItemRenderer method createColumnLabelProvider.
@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
if (!_lovInitialied) {
loadListBoxValues();
}
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 && _listValues != null && !_listValues.isEmpty()) {
ListBoxValue boxValue = null;
for (ListBoxValue val : _listValues.values()) {
if (val.getItemValue() == null && value == null) {
boxValue = val;
break;
}
if (val.getItemValue() == null) {
continue;
}
if (val.getItemValue().equals(value)) {
boxValue = val;
break;
}
}
if (boxValue != null) {
return boxValue.toString();
}
}
}
return "";
}
};
return provider;
}
use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.
the class EJRWTRadioGroupItemRenderer method createColumnLabelProvider.
@Override
public ColumnLabelProvider createColumnLabelProvider(final EJScreenItemProperties item, EJScreenItemController controller) {
final Map<Object, String> items = new HashMap<Object, String>();
EJFrameworkExtensionPropertyList radioButtons = _rendererProps.getPropertyList(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_RADIO_BUTTONS);
for (EJFrameworkExtensionPropertyListEntry listEntry : radioButtons.getAllListEntries()) {
Object value = getValueAsObject(_item.getReferencedItemProperties().getDataTypeClass(), listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_VALUE));
String lable = _item.getForm().translateText(listEntry.getProperty(EJRWTRadioButtonItemRendererDefinitionProperties.PROPERTY_LABEL));
items.put(value, lable);
}
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 items.get(value);
}
}
return "";
}
};
return provider;
}
use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.
the class EJRWTNumberItemRenderer 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;
}
};
}
use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.
the class EJRWTSingleRecordBlockRenderer method recordDeleted.
@Override
public void recordDeleted(int dataBlockRecordNumber) {
EJDataRecord recordAt = getRecordAt(dataBlockRecordNumber > 1 ? dataBlockRecordNumber - 2 : 0);
if (recordAt == null) {
recordAt = getLastRecord();
}
recordSelected(recordAt);
}
use of org.entirej.framework.core.data.EJDataRecord in project rap by entirej.
the class EJRWTSingleRecordBlockRenderer method buildGuiComponent.
@Override
public void buildGuiComponent(EJRWTEntireJGridPane blockCanvas) {
EJBlockProperties blockProperties = _block.getProperties();
EJMainScreenProperties mainScreenProperties = blockProperties.getMainScreenProperties();
EJFrameworkExtensionProperties brendererProperties = blockProperties.getBlockRendererProperties();
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = mainScreenProperties.getWidth();
gridData.heightHint = mainScreenProperties.getHeight();
gridData.horizontalSpan = mainScreenProperties.getHorizontalSpan();
gridData.verticalSpan = mainScreenProperties.getVerticalSpan();
gridData.grabExcessHorizontalSpace = mainScreenProperties.canExpandHorizontally();
gridData.grabExcessVerticalSpace = mainScreenProperties.canExpandVertically();
if (gridData.grabExcessHorizontalSpace) {
gridData.minimumWidth = mainScreenProperties.getWidth();
}
if (gridData.grabExcessVerticalSpace) {
gridData.minimumHeight = mainScreenProperties.getHeight();
}
blockCanvas.setLayoutData(gridData);
ScrolledComposite scrollComposite = null;
EJFrameworkExtensionProperties sectionProperties = null;
if (brendererProperties != null) {
sectionProperties = brendererProperties.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR);
}
if (sectionProperties != null && sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE);
if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TWISTIE.equals(mode)) {
style = style | ExpandableComposite.TWISTIE;
} else if (EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_TREE_NODE.equals(mode)) {
style = style | ExpandableComposite.TREE_NODE;
}
if (sectionProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
Section section = toolkit.createSection(blockCanvas, style);
section.setLayoutData(gridData);
String title = sectionProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_TITLE);
if (title != null) {
section.setText(title);
}
EJRWTImageRetriever.getGraphicsProvider().rendererSection(section);
String frameTitle = mainScreenProperties.getFrameTitle();
if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
Group group = new Group(section, SWT.NONE);
group.setLayout(new FillLayout());
group.setLayoutData(gridData);
scrollComposite = new EJRWTScrolledComposite(group, SWT.V_SCROLL | SWT.H_SCROLL);
_mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
group.setText(frameTitle);
section.setClient(group);
} else {
Composite composite = new Composite(blockCanvas, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
composite.setLayout(new FillLayout());
scrollComposite = new EJRWTScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL);
_mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
_mainPane.setLayoutData(gridData);
section.setClient(composite);
}
final EJFrameworkExtensionPropertyList propertyList = sectionProperties.getPropertyList(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTIONS);
if (propertyList != null && propertyList.getAllListEntries().size() > 0) {
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
final ToolBar toolbar = toolBarManager.createControl(section);
final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
toolbar.setCursor(handCursor);
// Cursor needs to be explicitly disposed
toolbar.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (handCursor != null && handCursor.isDisposed() == false) {
handCursor.dispose();
}
}
});
List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
final String actionID = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_ID);
String actionImage = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_IMAGE);
String actionName = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_NAME);
String actionTooltip = entry.getProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_ACTION_TOOLTIP);
if (actionID != null) {
Action action = new Action(actionID, IAction.AS_PUSH_BUTTON) {
@Override
public void runWithEvent(Event event) {
_block.executeActionCommand(actionID, EJScreenType.MAIN);
}
};
if (actionName != null) {
action.setText(actionName);
}
if (actionTooltip != null) {
action.setDescription(actionTooltip);
}
if (actionImage != null && actionImage.length() > 0) {
action.setImageDescriptor((EJRWTImageRetriever.createDescriptor(actionImage)));
}
toolBarManager.add(action);
}
}
toolBarManager.update(true);
section.setTextClient(toolbar);
}
} else {
String frameTitle = mainScreenProperties.getFrameTitle();
if (mainScreenProperties.getDisplayFrame() && frameTitle != null && frameTitle.length() > 0) {
Group group = new Group(blockCanvas, SWT.NONE);
group.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
group.setLayout(new FillLayout());
group.setLayoutData(gridData);
group.setText(frameTitle);
scrollComposite = new EJRWTScrolledComposite(group, SWT.V_SCROLL | SWT.H_SCROLL);
_mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
} else {
Composite composite = new Composite(blockCanvas, mainScreenProperties.getDisplayFrame() ? SWT.BORDER : SWT.NONE);
composite.setLayout(new FillLayout());
scrollComposite = new EJRWTScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL);
_mainPane = new EJRWTEntireJGridPane(scrollComposite, mainScreenProperties.getNumCols());
_mainPane.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_GROUP);
composite.setLayoutData(gridData);
}
}
EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
if (rendererProp != null) {
EJFrameworkExtensionProperties propertyGroup = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
if (propertyGroup != null) {
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_QUERY_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_INSERT_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_UPDATE_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_DELETE_KEY);
addActionKeyinfo(propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY), EJRWTSingleRecordBlockDefinitionProperties.ACTION_REFRESH_KEY);
}
}
hookKeyListener(_mainPane);
hookFocusListener(_mainPane);
_mainPane.cleanLayout();
EJDataRecord registeredRecord = _mainItemRegister.getRegisteredRecord();
_mainItemRegister.resetRegister();
EJItemGroupPropertiesContainer container = blockProperties.getScreenItemGroupContainer(EJScreenType.MAIN);
Collection<EJItemGroupProperties> itemGroupProperties = container.getAllItemGroupProperties();
for (EJItemGroupProperties ejItemGroupProperties : itemGroupProperties) {
createItemGroup(_mainPane, ejItemGroupProperties);
}
_mainItemRegister.clearRegisteredValues();
if (registeredRecord == null) {
registeredRecord = getFirstRecord();
}
if (registeredRecord != null) {
_mainItemRegister.register(registeredRecord);
}
_mainPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent arg0) {
setHasFocus(true);
}
});
if (scrollComposite != null) {
scrollComposite.setContent(_mainPane);
scrollComposite.setLayout(new FillLayout());
scrollComposite.setExpandHorizontal(true);
scrollComposite.setExpandVertical(true);
scrollComposite.setMinSize(_mainPane.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
}
}
Aggregations