use of org.entirej.framework.core.data.controllers.EJApplicationLevelParameter in project rap by entirej.
the class EJRWTBanner method createContainer.
@Override
public void createContainer(final EJRWTApplicationManager manager, Composite parent, final EJFrameworkExtensionProperties rendererprop) {
canvas = new Label(parent, getComponentStyle(rendererprop.getStringProperty(PROPERTY_ALIGNMENT), SWT.NONE));
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
String imagePath = null;
if (rendererprop != null) {
String paramName = rendererprop.getStringProperty(IMAGE_PARAM);
final String action = rendererprop.getStringProperty(ACTION);
if (action != null && !action.isEmpty()) {
final Cursor cursor = new Cursor(canvas.getDisplay(), SWT.CURSOR_HAND);
canvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
cursor.dispose();
}
});
canvas.setCursor(cursor);
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
EJApplicationActionProcessor applicationActionProcessor = manager.getApplicationActionProcessor();
if (applicationActionProcessor != null) {
try {
applicationActionProcessor.executeActionCommand(manager.getFrameworkManager(), action);
} catch (EJActionProcessorException e1) {
e1.printStackTrace();
}
}
}
});
}
if (paramName != null && paramName.length() > 0) {
final EJApplicationLevelParameter applicationLevelParameter = manager.getApplicationLevelParameter(paramName);
if (applicationLevelParameter != null) {
Object value = applicationLevelParameter.getValue();
imagePath = (String) value;
if (imagePath != null) {
updateImage(manager, imagePath);
} else {
imagePath = rendererprop.getStringProperty(IMAGE_PATH);
updateImage(manager, imagePath);
}
applicationLevelParameter.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
if (newValue != null) {
updateImage(manager, (String) newValue);
} else {
updateImage(manager, rendererprop.getStringProperty(IMAGE_PATH));
}
}
});
} else {
imagePath = rendererprop.getStringProperty(IMAGE_PATH);
updateImage(manager, imagePath);
}
} else {
imagePath = rendererprop.getStringProperty(IMAGE_PATH);
updateImage(manager, imagePath);
}
}
}
use of org.entirej.framework.core.data.controllers.EJApplicationLevelParameter in project rap by entirej.
the class EJRWTComboItemRenderer method connectLOVItems.
private void connectLOVItems() {
String lovDefName = _rendererProps.getStringProperty(EJRWTComboBoxRendererDefinitionProperties.LOV_DEFINITION_NAME);
if (lovDefName == null || lovDefName.trim().length() == 0) {
return;
}
String defName = lovDefName;
EJInternalForm form = _item.getForm();
if (lovDefName.indexOf('.') != -1) {
defName = lovDefName.substring(0, lovDefName.indexOf('.'));
} else {
EJMessage message = new EJMessage("No LovDefinition item has been chosen for the ComboBox renderer properties on item: " + _itemProperties.getName());
form.getFrameworkManager().getApplicationManager().getApplicationMessenger().handleMessage(message);
return;
}
if (_item.getBlock().getProperties().isReferenceBlock()) {
defName = String.format("%s.%s", _item.getBlock().getProperties().getName(), defName);
}
EJLovDefinitionProperties lovDef = form.getProperties().getLovDefinitionProperties(defName);
if (lovDef == null) {
return;
}
Collection<EJItemProperties> allItemProperties = lovDef.getBlockProperties().getAllItemProperties();
for (EJItemProperties ejItemProperties : allItemProperties) {
String defaultValue = ejItemProperties.getDefaultQueryValue();
if (defaultValue == null || defaultValue.trim().length() == 0) {
continue;
}
String paramTypeCode = defaultValue.substring(0, defaultValue.indexOf(':'));
String paramValue = defaultValue.substring(defaultValue.indexOf(':') + 1);
final Logger logger = LoggerFactory.getLogger(EJRWTComboItemRenderer.class);
if ("APP_PARAMETER".equals(paramTypeCode)) {
EJApplicationLevelParameter param = form.getApplicationLevelParameter(paramValue);
if (param != null) {
param.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
logger.debug("APP_PARAMETER:parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_loadComboBoxValues();
refreshCombo();
}
});
}
});
}
} else if ("FORM_PARAMETER".equals(paramTypeCode)) {
EJFormParameter param = form.getFormParameter(paramValue);
if (param != null) {
param.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
logger.debug("FORM_PARAMETER.parameterChanged %s.%s", _item.getBlock().getProperties().getName(), _item.getName());
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_loadComboBoxValues();
refreshCombo();
}
});
}
});
}
} else if ("BLOCK_ITEM".equals(paramTypeCode)) {
final String blockName = paramValue.substring(0, paramValue.indexOf('.'));
String itemName = paramValue.substring(paramValue.indexOf('.') + 1);
EJInternalEditableBlock block = form.getBlock(blockName);
if (block != null) {
final String itemBlock = _item.getBlock().getProperties().getName();
_lovInitialiedOnValueSet = true;
if (!itemBlock.equals(blockName) || _item.getScreenType() == EJScreenType.MAIN) {
block.getBlockController().addNewRecordFocusedListener(new EJNewRecordFocusedListener() {
@Override
public void focusedGained(EJDataRecord focusedRecord) {
logger.debug(String.format("BLOCK RECORD Changed %s", blockName));
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_loadComboBoxValues();
refreshCombo();
}
});
}
});
}
block.addDataItemValueChangedListener(itemName, new EJDataItemValueChangedListener() {
@Override
public void dataItemValueChanged(String itemName, EJDataRecord changedRecord, EJScreenType screenType) {
if (blockName.equals(itemBlock)) {
if (screenType == _item.getScreenType()) {
logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_loadComboBoxValues();
refreshCombo();
}
});
}
} else {
if (screenType == EJScreenType.MAIN) {
logger.debug(String.format("BLOCK_ITEM.valueChanged %s.%s", blockName, itemName));
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_loadComboBoxValues();
refreshCombo();
}
});
}
}
}
});
}
}
}
EJLovController lovController = form.getLovController(defName);
if (lovController == null) {
return;
}
}
use of org.entirej.framework.core.data.controllers.EJApplicationLevelParameter in project rap by entirej.
the class EJRWTStatusbar method createContainer.
@Override
public void createContainer(final EJRWTApplicationManager manager, Composite parent, EJFrameworkExtensionProperties rendererprop) {
int style = SWT.NONE;
panel = new Composite(parent, style);
panel.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
actionProcessor = manager.getApplicationActionProcessor();
final EJFrameworkExtensionPropertyList propertyList = rendererprop.getPropertyList(SECTIONS);
if (propertyList == null) {
return;
}
List<EJFrameworkExtensionPropertyListEntry> allListEntries = propertyList.getAllListEntries();
GridLayout layout = new GridLayout(allListEntries.size(), false);
panel.setLayout(layout);
for (EJFrameworkExtensionPropertyListEntry entry : allListEntries) {
Control control;
final String action = entry.getProperty(ACTION);
if (action != null && action.trim().length() > 0) {
final Link linkField;
String alignmentProperty = entry.getProperty(PROPERTY_ALIGNMENT);
// use workaround to make sure link also provide alignment
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals(PROPERTY_ALIGNMENT_LEFT)) {
control = linkField = new Link(panel, style);
} else if (alignmentProperty.equals(PROPERTY_ALIGNMENT_RIGHT)) {
EJRWTEntireJGridPane sub = new EJRWTEntireJGridPane(panel, 3);
control = sub;
sub.cleanLayout();
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
linkField = new Link(sub, style);
} else if (alignmentProperty.equals(PROPERTY_ALIGNMENT_CENTER)) {
EJRWTEntireJGridPane sub = new EJRWTEntireJGridPane(panel, 3);
control = sub;
sub.cleanLayout();
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
linkField = new Link(sub, style);
new Label(sub, SWT.NONE).setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
} else {
control = linkField = new Link(panel, style);
}
} else {
control = linkField = new Link(panel, style);
}
String paramName = entry.getProperty(PARAMETER);
if (paramName != null && paramName.length() > 0) {
final EJApplicationLevelParameter applicationLevelParameter = manager.getApplicationLevelParameter(paramName);
if (applicationLevelParameter != null) {
Object value = applicationLevelParameter.getValue();
linkField.setText(String.format("<a>%s</a>", (value == null ? "" : value.toString())));
applicationLevelParameter.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
linkField.setText(String.format("<a>%s</a>", (newValue == null ? "" : newValue.toString())));
}
});
}
}
if (actionProcessor != null) {
linkField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
actionProcessor.executeActionCommand(manager.getFrameworkManager(), action);
} catch (EJActionProcessorException e1) {
logger.error(e1.getMessage(), e);
}
}
});
}
// set VA
String visualAttribute = entry.getProperty(VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null && visualAttribute.length() > 0) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(va);
if (background != null) {
linkField.setBackground(background);
}
Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(va);
if (foreground != null) {
linkField.setForeground(foreground);
}
linkField.setFont(EJRWTVisualAttributeUtils.INSTANCE.getFont(va, linkField.getFont()));
}
}
linkField.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
control.setData(EJ_RWT.CUSTOM_VARIANT, "applayout");
} else {
final Label section = new Label(panel, getComponentStyle(entry.getProperty(PROPERTY_ALIGNMENT), SWT.NONE));
control = section;
section.setData(EJ_RWT.MARKUP_ENABLED, Boolean.TRUE);
String paramName = entry.getProperty(PARAMETER);
if (paramName != null && paramName.length() > 0) {
final EJApplicationLevelParameter applicationLevelParameter = manager.getApplicationLevelParameter(paramName);
if (applicationLevelParameter != null) {
Object value = applicationLevelParameter.getValue();
section.setText(value == null ? "" : value.toString());
applicationLevelParameter.addParameterChangedListener(new ParameterChangedListener() {
@Override
public void parameterChanged(String parameterName, Object oldValue, Object newValue) {
section.setText(newValue == null ? "" : newValue.toString());
}
});
}
}
// set VA
String visualAttribute = entry.getProperty(VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null && visualAttribute.length() > 0) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(va);
if (background != null) {
section.setBackground(background);
}
Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(va);
if (foreground != null) {
section.setForeground(foreground);
}
section.setFont(EJRWTVisualAttributeUtils.INSTANCE.getFont(va, section.getFont()));
}
}
}
GridData gridData = new GridData();
gridData.verticalAlignment = SWT.CENTER;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
control.setLayoutData(gridData);
boolean expand = Boolean.valueOf(entry.getProperty(EXPAND_X));
if (expand) {
gridData.grabExcessHorizontalSpace = true;
}
String width = entry.getProperty(WIDTH);
if (width != null && width.length() > 0) {
try {
gridData.widthHint = (Integer.parseInt(width));
} catch (Exception ex) {
// ignore
}
}
//
}
}
Aggregations