use of org.entirej.framework.core.properties.interfaces.EJItemGroupProperties 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
}
use of org.entirej.framework.core.properties.interfaces.EJItemGroupProperties in project rap by entirej.
the class EJRWTAbstractScreenRenderer method createItemGroup.
private void createItemGroup(Composite parent, EJItemGroupProperties groupProperties, EJScreenType screenType) {
if (groupProperties.isSeparator()) {
int style = SWT.SEPARATOR;
if (groupProperties.getSeparatorOrientation() == EJSeparatorOrientation.HORIZONTAL) {
style = style | SWT.HORIZONTAL;
} else {
style = style | SWT.VERTICAL;
}
Label layoutBody = new Label(parent, style);
layoutBody.setLayoutData(createItemGroupGridData(groupProperties));
switch(groupProperties.getSeparatorLineStyle()) {
case DASHED:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_dashed");
break;
case DOTTED:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_dotted");
break;
case DOUBLE:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator_double");
break;
default:
layoutBody.setData(EJ_RWT.CUSTOM_VARIANT, "separator");
break;
}
return;
}
EJRWTEntireJGridPane groupPane;
String frameTitle = groupProperties.getFrameTitle();
boolean hasGroup = groupProperties.dispayGroupFrame() && frameTitle != null && frameTitle.length() > 0;
if (hasGroup) {
Group group = new Group(parent, SWT.NONE);
group.setLayout(new FillLayout());
group.setLayoutData(createItemGroupGridData(groupProperties));
group.setText(frameTitle);
parent = group;
groupPane = new EJRWTEntireJGridPane(parent, groupProperties.getNumCols());
} else {
groupPane = new EJRWTEntireJGridPane(parent, groupProperties.getNumCols(), groupProperties.dispayGroupFrame() ? SWT.BORDER : SWT.NONE);
}
groupPane.getLayout().verticalSpacing = 1;
groupPane.setPaneName(groupProperties.getName());
if (!hasGroup) {
groupPane.setLayoutData(createItemGroupGridData(groupProperties));
}
Collection<EJScreenItemProperties> itemProperties = groupProperties.getAllItemProperties();
for (EJScreenItemProperties screenItemProperties : itemProperties) {
createScreenItem(groupPane, screenItemProperties, screenType);
}
// build sub groups
EJItemGroupPropertiesContainer groupPropertiesContainer = groupProperties.getChildItemGroupContainer();
Collection<EJItemGroupProperties> itemGroupProperties = groupPropertiesContainer.getAllItemGroupProperties();
for (EJItemGroupProperties ejItemGroupProperties : itemGroupProperties) {
createItemGroup(groupPane, ejItemGroupProperties, screenType);
}
}
Aggregations