use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties 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));
}
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTTreeTableRecordBlockRenderer method createScreenItem.
public ColumnLabelProvider createScreenItem(EJRWTTreeTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
if (itemProps.isSpacerItem()) {
return null;
}
EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
if (renderer != null) {
EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
String labelOrientation = blockProperties.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.COLUMN_ALIGNMENT);
int displayedWidth = blockProperties.getIntProperty(EJRWTTreeTableBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
// width
if (displayedWidth == 0) {
if (itemProps.getLabel() != null) {
// add
displayedWidth = itemProps.getLabel().length() + 2;
// offset
} else {
displayedWidth = 5;
}
}
String visualAttribute = blockProperties.getStringProperty(EJRWTTreeTableBlockDefinitionProperties.VISUAL_ATTRIBUTE_PROPERTY);
if (visualAttribute != null) {
EJCoreVisualAttributeProperties va = EJCoreProperties.getInstance().getVisualAttributesContainer().getVisualAttributeProperties(visualAttribute);
if (va != null) {
itemRenderer.setInitialVisualAttribute(va);
}
}
if (item.getProperties().getVisualAttributeProperties() != null) {
renderer.setVisualAttribute(item.getProperties().getVisualAttributeProperties());
}
TreeViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), displayedWidth, labelProvider, getComponentStyle(labelOrientation));
TreeColumn column = viewerColumn.getColumn();
EJ_RWT.setTestId(column, blockProperties.getName() + "." + itemProps.getReferencedItemName());
column.setData("KEY", itemProps.getReferencedItemName());
column.setData("VIEWER", viewerColumn);
column.setData("ITEM", item);
column.setToolTipText(itemProps.getHint());
ColumnInfo info = new ColumnInfo();
column.setData("INFO", info);
column.setMoveable(blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
column.setResizable(info.resizable = blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
if (blockProperties.getBooleanProperty(EJRWTTreeTableBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
if (columnSorter != null) {
new EJRWTTreeTableSortSelectionListener(_tableViewer, column, columnSorter, SWT.UP, false);
}
}
// ensure that the width property of the table column is in
// Characters
Font font = labelProvider.getFont(new Object());
if (font == null) {
font = _tableViewer.getTree().getFont();
}
if (font != null) {
float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
if (avgCharWidth > 0) {
// add
column.setWidth(info.width = ((int) ((column.getWidth() + 1) * avgCharWidth)));
// +1
// padding
}
}
return labelProvider;
}
}
return null;
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTTreeRecordBlockRenderer method createScreenItem.
public TreeNodeTextProvider createScreenItem(EJCoreMainScreenItemProperties itemProps) {
if (itemProps.isSpacerItem()) {
return null;
}
EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
if (renderer != null) {
EJFrameworkExtensionProperties blockProperties = itemProps.getBlockRendererRequiredProperties();
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
return new TreeNodeTextProvider(blockProperties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_PREFIX), blockProperties.getStringProperty(EJRWTTreeBlockDefinitionProperties.ITEM_SUFFIX), labelProvider);
}
}
return null;
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTComboItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
_actionControl = new EJRWTAbstractActionCombo(composite) {
private static final long serialVersionUID = 2592484612013403481L;
@Override
public Combo createCombo(Composite parent) {
String alignmentProperty = _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
if (alignmentProperty == null) {
alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
}
String hint = _screenItemProperties.getHint();
int style = SWT.READ_ONLY;
style = getComponentStyle(alignmentProperty, style);
_comboField = new Combo(parent, style);
_comboField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_COMBOBOX);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_comboField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
_comboViewer = new ComboViewer(_comboField);
if (hint != null && hint.trim().length() > 0) {
_comboField.setToolTipText(hint);
}
_comboField.setData(_item.getReferencedItemProperties().getName());
if (_visibleItemCount > 5) {
_comboField.setVisibleItemCount(_visibleItemCount);
}
_comboField.addFocusListener(EJRWTComboItemRenderer.this);
_comboViewer.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ComboBoxValue) {
ComboBoxValue value = (ComboBoxValue) element;
return value.getItemValueAsString();
}
return "";
}
});
_comboViewer.setContentProvider(new ArrayContentProvider());
_comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!_activeEvent)
return;
Object old = _baseValue;
if (isValid()) {
ComboBoxValue value = getComboBoxValue();
_item.itemValueChaged(value.getItemValue());
if (value != null) {
value.populateReturnItems(_item.getBlock().getBlockController(), _item.getScreenType());
}
setMandatoryBorder(_mandatory);
} else {
_isValid = true;
}
_item.executeActionCommand();
}
});
return _comboField;
}
@Override
public Control createActionLabel(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setImage(EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_FIND_LOV));
label.addFocusListener(EJRWTComboItemRenderer.this);
label.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent arg0) {
_item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
}
@Override
public void mouseDown(MouseEvent arg0) {
}
@Override
public void mouseDoubleClick(MouseEvent arg0) {
}
});
final EJFrameworkExtensionProperties rendererProp = EJCoreProperties.getInstance().getApplicationDefinedProperties();
final EJFrameworkExtensionProperties propertyGroup = rendererProp.getPropertyGroup(EJRWTSingleRecordBlockDefinitionProperties.ACTION_GROUP);
String lovKey = "SHIFT+ARROW_DOWN";
if (propertyGroup != null) {
lovKey = propertyGroup.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ACTION_LOV_KEY);
}
if (lovKey == null) {
lovKey = "SHIFT+ARROW_DOWN";
}
label.setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
getComboControl().setData(EJ_RWT.ACTIVE_KEYS, new String[] { lovKey });
addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent arg0) {
if ((arg0.stateMask & SWT.SHIFT) != 0 && arg0.keyCode == SWT.ARROW_DOWN && isLovActivated()) {
_item.getItemLovController().displayLov(EJLovDisplayReason.LOV);
}
}
@Override
public void keyPressed(KeyEvent arg0) {
}
});
return label;
}
};
_visualContext = new EJRWTItemRendererVisualContext(_comboField.getBackground(), _comboField.getForeground(), _comboField.getFont());
_mandatoryDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
_errorDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
_mandatoryDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_REQUIRED));
_mandatoryDecoration.setShowHover(true);
_mandatoryDecoration.setDescriptionText(_screenItemProperties.getLabel() == null || _screenItemProperties.getLabel().isEmpty() ? "Required Item" : String.format("%s is required", _screenItemProperties.getLabel()));
if (_isValid) {
_errorDecoration.hide();
}
if (message != null) {
setMessage(message);
}
_mandatoryDecoration.hide();
refreshCombo();
setInitialValue(_baseValue);
}
use of org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties in project rap by entirej.
the class EJRWTStandardLovRenderer method createScreenItem.
public ColumnLabelProvider createScreenItem(EJRWTTableViewerColumnFactory factory, EJCoreMainScreenItemProperties itemProps) {
if (itemProps.isSpacerItem()) {
return null;
}
EJScreenItemController item = _block.getScreenItem(EJScreenType.MAIN, itemProps.getReferencedItemName());
EJManagedItemRendererWrapper renderer = item.getManagedItemRenderer();
if (renderer != null) {
EJFrameworkExtensionProperties blockProperties = itemProps.getLovRendererRequiredProperties();
EJRWTAppItemRenderer itemRenderer = (EJRWTAppItemRenderer) renderer.getUnmanagedRenderer();
ColumnLabelProvider labelProvider = itemRenderer.createColumnLabelProvider(itemProps, item);
if (labelProvider != null) {
int _widthHint = blockProperties.getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
// width
if (_widthHint == 0) {
if (itemProps.getLabel() != null) {
// offset
_widthHint = itemProps.getLabel().length() + 2;
} else {
_widthHint = 5;
}
}
String alignmentProperty = blockProperties.getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
TableViewerColumn viewerColumn = factory.createColumn(itemProps.getLabel(), _widthHint, labelProvider, getComponentStyle(alignmentProperty));
TableColumn column = viewerColumn.getColumn();
column.setToolTipText(itemProps.getHint());
column.setMoveable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_REORDER, true));
column.setResizable(blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_COLUMN_RESIZE, true));
if (blockProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.ALLOW_ROW_SORTING, true)) {
EJRWTAbstractTableSorter columnSorter = itemRenderer.getColumnSorter(itemProps, item);
if (columnSorter != null) {
new EJRWTTableSortSelectionListener(_tableViewer, column, columnSorter, SWT.UP, false);
}
}
// ensure that the width property of the table column is in
// Characters
Font font = labelProvider.getFont(new Object());
if (font == null) {
font = _tableViewer.getTable().getFont();
}
if (font != null) {
float avgCharWidth = EJRWTImageRetriever.getGraphicsProvider().getAvgCharWidth(font);
if (avgCharWidth > 0) {
// add
column.setWidth((int) ((column.getWidth() + 1) * avgCharWidth));
// +1
// padding
}
}
return labelProvider;
}
}
return null;
}
Aggregations