use of org.entirej.framework.core.properties.EJCoreMainScreenItemProperties in project rap by entirej.
the class EJRWTPieChartRecordBlockRenderer method processAction.
protected void processAction(String method, JsonObject parameters) {
if (method.equals("_pie_select")) {
if (parameters.names().contains("label") && parameters.names().contains("value")) {
currentRecord = null;
EJScreenItemController dataItem = null;
List<EJScreenItemController> screenItems = getScreenItems();
for (EJScreenItemController sItem : screenItems) {
String label = sItem.getProperties().getLabel();
if (label.trim().isEmpty()) {
label = sItem.getProperties().getReferencedItemName();
}
if (label.equals(parameters.get("label").asString())) {
dataItem = sItem;
break;
}
}
if (dataItem != null) {
// Collection<EJDataRecord> records = _block.getRecords();
// Object lastVal=null;
// for (EJDataRecord record : records)
// {
// Object value = record.getValue(dataItem.getName());
// if(value==null)
// value = lastVal;
//
// if (
// value != null && value.equals(parameters.get("value").asDouble()))
// {
// currentRecord = record;
// break;
// }
// lastVal = value;
//
// }
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) dataItem.getProperties();
String action = mainScreenItemProperties.getBlockRendererRequiredProperties().getStringProperty("action");
if (action != null && !action.trim().isEmpty()) {
_block.executeActionCommand(action, EJScreenType.MAIN);
}
}
}
}
}
use of org.entirej.framework.core.properties.EJCoreMainScreenItemProperties in project rap by entirej.
the class EJRWTStackedItemRenderer method extractValuetoUi.
private void extractValuetoUi() {
if (!controlState(stackedPane))
return;
try {
enableLovActivation(false);
_item.setItemLovMapping(null);
_actionControl.setCustomActionVisible(_baseValue != null && _baseValue.getConfig().getType() == EJRWTStackedItemRendererType.DATE);
if (_baseValue != null) {
if (controlState(_label) && !(_baseValue.getConfig().getType() == EJRWTStackedItemRendererType.SPACER || _baseValue.getConfig().getType() == EJRWTStackedItemRendererType.CHECKBOX || _baseValue.getConfig().getType() == EJRWTStackedItemRendererType.BUTTON)) {
if (_baseValue.getConfig().getLabel() != null) {
setLabel(_baseValue.getConfig().getLabel());
} else {
setLabel(_screenItemProperties.getLabel() == null ? "" : _screenItemProperties.getLabel());
}
}
if (_baseValue.getConfig().getType() == EJRWTStackedItemRendererType.COMBO) {
EJRWTStackedItemRendererConfig.Combo config = (EJRWTStackedItemRendererConfig.Combo) _baseValue.getConfig();
Combo control = (Combo) stackedPane.getControl(_baseValue.getConfig().getType().name());
if (control.getData("CONFIG") != config) {
List<ComboBoxValue> loadComboBoxValues = loadComboBoxValues(config);
((ComboViewer) control.getData("VIEW")).setInput(loadComboBoxValues);
control.setData("CONFIG", config);
if (config.getVisibleItemCount() > 5) {
control.setVisibleItemCount(config.getVisibleItemCount());
}
}
}
if (_baseValue.getConfig().getTooltip() != null) {
setHint(_baseValue.getConfig().getLabel());
} else {
setHint(_screenItemProperties.getHint() == null ? "" : _screenItemProperties.getHint());
}
stackedPane.showPane(_baseValue.getConfig().getType().name());
if (_baseValue.getConfig().getExpandHorizontally() != null) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_actionControl.getData("data.ExpandH") == null)
_actionControl.setData("data.ExpandH", data.grabExcessHorizontalSpace);
if (_actionControl.getData("data.HA") == null)
_actionControl.setData("data.HA", data.horizontalAlignment);
data.grabExcessHorizontalSpace = _baseValue.getConfig().getExpandHorizontally();
data.horizontalAlignment = data.grabExcessHorizontalSpace ? SWT.FILL : SWT.BEGINNING;
}
} else {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
if (_actionControl.getData("data.ExpandH") != null) {
data.grabExcessHorizontalSpace = (Boolean) _actionControl.getData("data.ExpandH");
data.horizontalAlignment = (Integer) _actionControl.getData("data.HA");
_actionControl.setData("data.ExpandH", null);
_actionControl.setData("data.HA", null);
}
}
}
if (_baseValue.getConfig().getExpandVertically() != null) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_actionControl.getData("data.ExpandV") == null)
_actionControl.setData("data.ExpandV", data.grabExcessVerticalSpace);
if (_actionControl.getData("data.VA") == null)
_actionControl.setData("data.VA", data.verticalAlignment);
data.grabExcessVerticalSpace = _baseValue.getConfig().getExpandVertically();
data.verticalAlignment = data.grabExcessVerticalSpace ? SWT.FILL : SWT.TOP;
}
if (_label != null) {
layoutData = _label.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_label.getData("data.VA") == null)
_label.setData("data.VA", data.verticalAlignment);
if (_label.getData("data.VI") == null)
_label.setData("data.VI", data.verticalIndent);
data.verticalIndent = 2;
data.verticalAlignment = SWT.TOP;
}
}
} else {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
if (_actionControl.getData("data.ExpandV") != null) {
data.grabExcessVerticalSpace = (Boolean) _actionControl.getData("data.ExpandV");
data.verticalAlignment = (Integer) _actionControl.getData("data.VA");
_actionControl.setData("data.ExpandV", null);
_actionControl.setData("data.VA", null);
}
}
if (_label != null) {
layoutData = _label.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_label.getData("data.VA") != null)
data.verticalAlignment = (Integer) _label.getData("data.VA");
if (_label.getData("data.VI") != null)
data.verticalIndent = (Integer) _label.getData("data.VI");
}
}
}
if (_baseValue.getConfig().getXSpan() != EJRWTStackedItemRendererConfig.DEFUALT) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_actionControl.getData("data.xspan") == null)
_actionControl.setData("data.xspan", data.horizontalSpan);
data.horizontalSpan = _baseValue.getConfig().getXSpan();
}
} else {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
if (_actionControl.getData("data.xspan") != null) {
data.horizontalSpan = (Integer) _actionControl.getData("data.xspan");
_actionControl.setData("data.xspan", null);
}
}
}
if (_baseValue.getConfig().getYSpan() != EJRWTStackedItemRendererConfig.DEFUALT) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_actionControl.getData("data.yspan") == null)
_actionControl.setData("data.yspan", data.verticalSpan);
data.verticalSpan = _baseValue.getConfig().getYSpan();
}
} else {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
if (_actionControl.getData("data.yspan") != null) {
data.verticalSpan = (Integer) _actionControl.getData("data.yspan");
_actionControl.setData("data.yspan", null);
}
}
}
if (_baseValue.getConfig().getWidth() != EJRWTStackedItemRendererConfig.DEFUALT) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
float avgCharHeight = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(control.getFont());
if (_actionControl.getData("data.widthHint") == null)
_actionControl.setData("data.widthHint", data.widthHint);
data.widthHint = (int) (avgCharHeight * (_baseValue.getConfig().getWidth() + 1));
}
} else {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
if (_actionControl.getData("data.widthHint") != null) {
data.widthHint = (Integer) _actionControl.getData("data.widthHint");
_actionControl.setData("data.widthHint", null);
}
}
}
if (_baseValue.getConfig().getType() == EJRWTStackedItemRendererType.TEXT_AREA) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
EJRWTStackedItemRendererConfig.TextArea config = (TextArea) _baseValue.getConfig();
Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
float avgCharHeight = EJRWTImageRetriever.getGraphicsProvider().getCharHeight(control.getFont());
// add padding
if (config.getLines() > 0) {
if (_actionControl.getData("data.heightHint") == null)
_actionControl.setData("data.heightHint", data.heightHint);
data.heightHint = (int) ((config.getLines() + 1) * avgCharHeight);
}
}
if (_label != null) {
layoutData = _label.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_label.getData("data.VA") == null)
_label.setData("data.VA", data.verticalAlignment);
if (_label.getData("data.VI") == null)
_label.setData("data.VI", data.verticalIndent);
data.verticalIndent = 2;
data.verticalAlignment = SWT.TOP;
}
}
} else if (_baseValue.getConfig().getHeight() != EJRWTStackedItemRendererConfig.DEFUALT) {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
Control control = stackedPane.getControl(_baseValue.getConfig().getType().name());
float avgCharHeight = EJRWTImageRetriever.getGraphicsProvider().getCharHeight(control.getFont());
if (_actionControl.getData("data.heightHint") == null)
_actionControl.setData("data.heightHint", data.heightHint);
data.heightHint = (int) (avgCharHeight * (_baseValue.getConfig().getHeight() + 1));
}
if (_label != null) {
layoutData = _label.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_label.getData("data.VA") == null)
_label.setData("data.VA", data.verticalAlignment);
if (_label.getData("data.VI") == null)
_label.setData("data.VI", data.verticalIndent);
data.verticalIndent = 2;
data.verticalAlignment = SWT.TOP;
}
}
} else {
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
// add padding
if (_actionControl.getData("data.heightHint") != null) {
data.heightHint = (Integer) _actionControl.getData("data.heightHint");
_actionControl.setData("data.heightHint", null);
}
}
if (_label != null) {
layoutData = _label.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_label.getData("data.VA") != null)
data.verticalAlignment = (Integer) _label.getData("data.VA");
if (_label.getData("data.VI") != null)
data.verticalIndent = (Integer) _label.getData("data.VI");
}
}
}
// setLOV mapping
if (_baseValue.getConfig() instanceof EJRWTStackedItemRendererConfig.ActionSupportConfig) {
if (_item.getProperties() instanceof EJCoreInsertScreenItemProperties) {
((EJCoreInsertScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
} else if (_item.getProperties() instanceof EJCoreQueryScreenItemProperties) {
((EJCoreQueryScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
} else if (_item.getProperties() instanceof EJCoreUpdateScreenItemProperties) {
((EJCoreUpdateScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
} else if (_item.getProperties() instanceof EJCoreMainScreenItemProperties) {
((EJCoreMainScreenItemProperties) _item.getProperties()).setActionCommand(((EJRWTStackedItemRendererConfig.ActionSupportConfig) _baseValue.getConfig()).getActionCommand());
}
}
if (_baseValue.getConfig() instanceof EJRWTStackedItemRendererConfig.LOVSupportConfig) {
EJRWTStackedItemRendererConfig.LOVSupportConfig lovMapping = (LOVSupportConfig) _baseValue.getConfig();
_item.getProperties().enableLovNotification(lovMapping.isLovEnabled());
_item.setItemLovMapping(lovMapping.getLovMapping());
_item.getProperties().enableLovValidation(lovMapping.isValidateLov());
enableLovActivation(lovMapping.isLovEnabled());
}
setStackValue();
} else {
// switch
stackedPane.showPane(EJRWTStackedItemRendererType.SPACER.name());
Object layoutData = _actionControl.getLayoutData();
if (layoutData instanceof GridData) {
GridData data = (GridData) layoutData;
if (_actionControl.getData("data.heightHint") != null) {
data.heightHint = (Integer) _actionControl.getData("data.heightHint");
_actionControl.setData("data.heightHint", null);
}
if (_actionControl.getData("data.xspan") != null) {
data.horizontalSpan = (Integer) _actionControl.getData("data.xspan");
_actionControl.setData("data.xspan", null);
}
if (_actionControl.getData("data.yspan") != null) {
data.verticalSpan = (Integer) _actionControl.getData("data.yspan");
_actionControl.setData("data.yspan", null);
}
if (_actionControl.getData("data.ExpandV") != null) {
data.grabExcessVerticalSpace = (Boolean) _actionControl.getData("data.ExpandV");
data.verticalAlignment = (Integer) _actionControl.getData("data.VA");
_actionControl.setData("data.ExpandV", null);
_actionControl.setData("data.VA", null);
}
if (_actionControl.getData("data.ExpandH") != null) {
data.grabExcessHorizontalSpace = (Boolean) _actionControl.getData("data.ExpandH");
data.horizontalAlignment = (Integer) _actionControl.getData("data.HA");
_actionControl.setData("data.ExpandH", null);
_actionControl.setData("data.HA", null);
}
if (_label != null) {
layoutData = _label.getLayoutData();
if (layoutData instanceof GridData) {
GridData ldata = (GridData) layoutData;
if (_label.getData("data.VA") != null)
ldata.verticalAlignment = (Integer) _label.getData("data.VA");
if (_label.getData("data.VI") != null)
ldata.verticalIndent = (Integer) _label.getData("data.VI");
}
}
}
// to
// empty
}
} finally {
_actionControl.getParent().layout();
}
}
use of org.entirej.framework.core.properties.EJCoreMainScreenItemProperties in project rap by entirej.
the class EJRWTStandardLovRenderer method buildGui.
protected void buildGui() {
int width = _lovController.getDefinitionProperties().getWidth();
int height = _lovController.getDefinitionProperties().getHeight();
_dialog = new EJRWTAbstractDialog(getRWTManager().getShell()) {
private static final long serialVersionUID = -4685316941898120169L;
private EJRWTAbstractFilteredTable filterTree;
private String defaultMessage;
@Override
public boolean close() {
_tableViewer = null;
_dialog = null;
return super.close();
}
@Override
public void activateDialog() {
super.activateDialog();
filterTree.getFilterControl().forceFocus();
}
@Override
public void createBody(Composite parent) {
GridLayout layout = new GridLayout();
EJ_RWT.setTestId(parent, "lov." + _lovController.getProperties().getLovDefinition().getName());
layout.marginWidth = 0;
// layout.horizontalSpacing = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginHeight = 0;
// layout.verticalSpacing = 0;
layout.marginBottom = 0;
layout.marginTop = 0;
parent.setLayout(layout);
int style = SWT.VIRTUAL;
EJFrameworkExtensionProperties rendererProp = _lovController.getDefinitionProperties().getLovRendererProperties();
if (!rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.HIDE_TABLE_BORDER, false)) {
style = style | SWT.BORDER;
}
defaultMessage = rendererProp.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_MESSAGE);
;
Table table;
filterTree = new EJRWTAbstractFilteredTable(parent, style) {
@Override
public void filter(String filter) {
if (_filteredContentProvider != null && (filter == null && _filteredContentProvider.getFilter() != null || !filter.equals(_filteredContentProvider.getFilter()))) {
_filteredContentProvider.setFilter(filter);
getViewer().setInput(filter);
getViewer().getTable().select(0);
}
}
@Override
protected boolean doCreateCustomComponents(Composite parent) {
return createToolbar(parent) != null;
}
@Override
protected TableViewer doCreateTableViewer(Composite parent, int style) {
_tableViewer = new TableViewer(new Table(parent, style));
return _tableViewer;
}
};
if (defaultMessage != null)
filterTree.getFilterControl().setMessage(defaultMessage);
EJ_RWT.setTestId(filterTree.getFilterControl(), "lov-search");
table = (_tableViewer = filterTree.getViewer()).getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
table.setLinesVisible(rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_VERTICAL_LINES, true));
table.setHeaderVisible(rendererProp.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true));
EJRWTTableViewerColumnFactory factory = new EJRWTTableViewerColumnFactory(_tableViewer);
ColumnViewerToolTipSupport.enableFor(_tableViewer);
Collection<EJItemGroupProperties> allItemGroupProperties = _block.getProperties().getScreenItemGroupContainer(EJScreenType.MAIN).getAllItemGroupProperties();
final List<ColumnLabelProvider> nodeTextProviders = new ArrayList<ColumnLabelProvider>();
for (EJItemGroupProperties groupProperties : allItemGroupProperties) {
Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
for (EJScreenItemProperties screenItemProperties : itemProperties) {
EJCoreMainScreenItemProperties mainScreenItemProperties = (EJCoreMainScreenItemProperties) screenItemProperties;
ColumnLabelProvider screenItem = createScreenItem(factory, mainScreenItemProperties);
if (screenItem != null) {
nodeTextProviders.add(screenItem);
}
}
}
final EJBlockController blockController = _block.getBlockController();
// _mainPane.addControlListener(new
// TableAutoResizeAdapter(table));
/*
* _tableViewer.setContentProvider(new ILazyContentProvider() {
*
* @Override public void inputChanged(Viewer arg0, Object arg1,
* Object arg2) {
* _tableViewer.setItemCount(blockController.getDataBlock().
* getBlockRecordCount());
*
* }
*
* @Override public void dispose() { // TODO Auto-generated
* method stub
*
* }
*
* @Override public void updateElement(int index) { EJDataRecord
* record = null; if (index <=
* blockController.getDataBlock().getBlockRecordCount()) {
* record = blockController.getDataBlock().getRecord(index);
*
* } _tableViewer.replace(record, index);
*
* } });
*/
_tableViewer.setContentProvider(_filteredContentProvider = new FilteredContentProvider() {
private static final long serialVersionUID = 7262009393527533868L;
boolean matchItem(EJDataRecord rec) {
if (filter != null && filter.trim().length() > 0) {
for (ColumnLabelProvider filterTextProvider : nodeTextProviders) {
String text = filterTextProvider.getText(rec);
if (text != null && text.toLowerCase().contains(filter.toLowerCase())) {
return true;
}
}
}
return false;
}
@Override
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
_tableBaseRecords.clear();
if (arg2 != null && arg2.equals(filter) && filter.trim().length() > 0) {
for (EJDataRecord record : blockController.getBlock().getRecords()) {
if (matchItem(record)) {
_tableBaseRecords.add(record);
}
}
} else {
filter = null;
if (filterTree != null) {
filterTree.clearText();
}
_tableBaseRecords.addAll(blockController.getBlock().getRecords());
}
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object arg0) {
return _tableBaseRecords.toArray();
}
});
_tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent arg0) {
buttonPressed(OK_ACTION_COMMAND);
}
});
_tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent arg0) {
if (!_validate) {
return;
}
_validate = false;
try {
EJDataRecord record = getFocusedRecord();
if (_lovController.getFocusedRecord() == null || _lovController.getFocusedRecord() != record) {
_lovController.newRecordInstance(record);
}
} finally {
_validate = true;
}
}
});
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
EJ_RWT.setTestId(createButton(parent, OK_ACTION_COMMAND, "OK", true), "ok");
EJ_RWT.setTestId(createButton(parent, CANCEL_ACTION_COMMAND, "Cancel", false), "cancel");
}
@Override
public void canceled() {
_lovController.lovCompleted(_itemToValidate, null);
close();
}
@Override
protected void buttonPressed(int buttonId) {
switch(buttonId) {
case OK_ACTION_COMMAND:
{
_lovController.lovCompleted(_itemToValidate, _lovController.getFocusedRecord());
if (_dialog != null) {
_dialog.close();
}
break;
}
case CANCEL_ACTION_COMMAND:
{
_lovController.lovCompleted(_itemToValidate, null);
if (_dialog != null) {
_dialog.close();
}
break;
}
default:
_lovController.lovCompleted(_itemToValidate, null);
break;
}
super.buttonPressed(buttonId);
}
};
_dialog.create();
_tableViewer.setInput(new Object());
selectRow(0);
// add dialog
_dialog.getShell().setSize(width + 80, height + 100);
// border
// offsets
}
Aggregations