use of org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties in project rap by entirej.
the class EJRWTMultiRecordBlockDefinition method addTable.
private EJRWTTableRendererDefinitionControl addTable(EJDevBlockDisplayProperties blockDisplayProperties, Composite client, FormToolkit toolkit) {
Map<String, Integer> columnPositions = new HashMap<String, Integer>();
final ScrolledForm sc = toolkit.createScrolledForm(client);
GridData scgd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
scgd.grabExcessHorizontalSpace = true;
scgd.grabExcessVerticalSpace = true;
sc.setLayoutData(scgd);
GridLayout gl = new GridLayout();
gl.marginHeight = gl.marginWidth = 0;
sc.getBody().setLayout(gl);
toolkit.adapt(sc);
sc.getBody().setLayout(new FillLayout());
Composite tablePanel = sc.getBody();
EJDevItemGroupDisplayProperties displayProperties = null;
if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
if (displayProperties.dispayGroupFrame()) {
Group group = new Group(tablePanel, SWT.NONE);
group.setLayout(new FillLayout());
if (displayProperties.getFrameTitle() != null && displayProperties.getFrameTitle().length() > 0)
group.setText(displayProperties.getFrameTitle());
tablePanel = group;
}
}
Table table = new Table(tablePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
// There is only one item group for a flow layout
int itemCount = 0;
if (displayProperties != null)
for (EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
if (!screenItem.isSpacerItem()) {
int width = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties().getIntProperty(EJRWTMultiRecordBlockDefinitionProperties.DISPLAY_WIDTH_PROPERTY, 0);
TableColumn masterColumn = new TableColumn(table, SWT.NONE);
masterColumn.setData("SCREEN_ITEM", screenItem);
masterColumn.setText(screenItem.getLabel());
masterColumn.setWidth(width);
String alignment = ((EJDevMainScreenItemDisplayProperties) screenItem).getBlockRendererRequiredProperties().getStringProperty(EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALIGNMENT);
if (EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALLIGN_RIGHT.equals(alignment)) {
masterColumn.setAlignment(SWT.RIGHT);
} else if (EJRWTMultiRecordBlockDefinitionProperties.COLUMN_ALLIGN_CENTER.equals(alignment)) {
masterColumn.setAlignment(SWT.CENTER);
}
ColumnWeightData colData = new ColumnWeightData(5, 50, true);
tableLayout.addColumnData(colData);
columnPositions.put(screenItem.getReferencedItemName(), itemCount);
itemCount++;
}
}
table.setLayout(tableLayout);
return new EJRWTTableRendererDefinitionControl(blockDisplayProperties, table, columnPositions);
}
use of org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties in project rap by entirej.
the class EJRWTBlockPreviewerCreator method addItemGroup.
private void addItemGroup(Composite parent, EJDevBlockRendererDefinition blockRendererDef, EJDevBlockDisplayProperties blockDisplayProperties, EJDevItemGroupDisplayProperties itemGroupProperties, FormToolkit toolkit, List<EJDevItemRendererDefinitionControl> itemControls) {
if (itemGroupProperties.isSeparator()) {
int style = SWT.SEPARATOR;
if (itemGroupProperties.getSeparatorOrientation() == EJSeparatorOrientation.HORIZONTAL) {
style = style | SWT.HORIZONTAL;
} else {
style = style | SWT.VERTICAL;
}
Label layoutBody = new Label(parent, style);
layoutBody.setLayoutData(createItemGroupGridData(itemGroupProperties));
return;
}
Composite group = null;
if (itemGroupProperties.dispayGroupFrame()) {
if (itemGroupProperties.getFrameTitle() == null) {
group = new Composite(parent, SWT.SHADOW_NONE);
group.setLayoutData(createItemGroupGridData(itemGroupProperties));
} else {
EJFrameworkExtensionProperties rendererProperties = itemGroupProperties.getRendererProperties();
if (rendererProperties != null && rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE) != null && !EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE_GROUP.equals(rendererProperties.getStringProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_MODE))) {
int style = ExpandableComposite.TITLE_BAR;
String mode = rendererProperties.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 (rendererProperties.getBooleanProperty(EJRWTSingleRecordBlockDefinitionProperties.ITEM_GROUP_TITLE_BAR_EXPANDED, true)) {
style = style | ExpandableComposite.EXPANDED;
}
Section section = toolkit.createSection(parent, style);
section.setFont(parent.getFont());
section.setText(itemGroupProperties.getFrameTitle());
group = toolkit.createComposite(section);
section.setLayoutData(createItemGroupGridData(itemGroupProperties));
section.setClient(group);
} else {
group = new Group(parent, SWT.SHADOW_ETCHED_IN);
((Group) group).setText(itemGroupProperties.getFrameTitle());
group.setLayoutData(createItemGroupGridData(itemGroupProperties));
}
}
} else {
group = new Composite(parent, SWT.SHADOW_NONE);
group.setLayoutData(createItemGroupGridData(itemGroupProperties));
}
// toolkit.adapt(group);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = itemGroupProperties.getNumCols();
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
group.setLayout(gridLayout);
ItemCreator itemCreator = new ItemCreator();
for (EJDevScreenItemDisplayProperties definition : itemGroupProperties.getAllItemDisplayProperties()) {
if (definition.isSpacerItem()) {
EJDevItemRendererDefinitionControl control = itemCreator.addSpacerItem(blockRendererDef, group, definition, toolkit);
itemControls.add(control);
} else {
EJDevBlockItemDisplayProperties blockItemProperties = blockDisplayProperties.getBlockItemDisplayContainer().getItemProperties(definition.getReferencedItemName());
if (blockItemProperties == null) {
throw new IllegalStateException("Unable to retrrieve the blockItemProperties for: " + definition.getBlockName() + ":" + definition.getBlockItemDisplayProperties().getName());
}
EJDevItemRendererDefinitionControl control = itemCreator.createItem(itemGroupProperties.getNumCols(), blockItemProperties, (EJDevMainScreenItemDisplayProperties) definition, group, toolkit);
itemControls.add(control);
}
}
for (EJDevItemGroupDisplayProperties subGroup : itemGroupProperties.getChildItemGroupContainer().getAllItemGroupDisplayProperties()) {
addItemGroup(group, blockRendererDef, blockDisplayProperties, subGroup, toolkit, itemControls);
}
toolkit.paintBordersFor(group);
}
use of org.entirej.framework.dev.properties.interfaces.EJDevScreenItemDisplayProperties in project rap by entirej.
the class EJRWTHtmlTableBlockRendererDefinition method addBlockControlToCanvas.
@Override
public EJDevBlockRendererDefinitionControl addBlockControlToCanvas(EJMainScreenProperties mainScreenProperties, EJDevBlockDisplayProperties blockDisplayProperties, Composite parent, FormToolkit toolkit) {
Composite layoutBody;
if (mainScreenProperties.getDisplayFrame()) {
if (mainScreenProperties.getFrameTitle() != null && mainScreenProperties.getFrameTitle().length() > 0) {
layoutBody = new Group(parent, SWT.NONE);
((Group) layoutBody).setText(mainScreenProperties.getFrameTitle());
} else {
layoutBody = new Composite(parent, SWT.BORDER);
}
} else {
layoutBody = new Composite(parent, SWT.NONE);
}
layoutBody.setLayout(new FillLayout());
if (System.getProperty("os.name").toLowerCase().indexOf("win") > -1) {
Label label = new Label(layoutBody, SWT.NONE);
label.setText("HTML Table Block");
return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
EJDevItemGroupDisplayProperties displayProperties = null;
if (blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().size() > 0) {
displayProperties = blockDisplayProperties.getMainScreenItemGroupDisplayContainer().getAllItemGroupDisplayProperties().iterator().next();
}
EJFrameworkExtensionProperties blockRendererProperties = mainScreenProperties.getBlockProperties().getBlockRendererProperties();
boolean addHeader = true;
StringBuilder header = new StringBuilder();
if (blockRendererProperties != null) {
addHeader = blockRendererProperties.getBooleanProperty(EJRWTMultiRecordBlockDefinitionProperties.SHOW_HEADING_PROPERTY, true);
}
int cellPadding = blockDisplayProperties.getBlockRendererProperties().getIntProperty(CELL_PADDING_PROPERTY, 0);
String paddingStyle = null;
if (cellPadding > 0) {
String str = String.valueOf(cellPadding);
paddingStyle = String.format("padding: %spx %spx %spx %spx; ", str, str, str, str);
}
if (displayProperties != null) {
for (final EJDevScreenItemDisplayProperties screenItem : displayProperties.getAllItemDisplayProperties()) {
if (screenItem.isSpacerItem()) {
continue;
}
if (addHeader) {
String styleClass = "default_all";
EJFrameworkExtensionProperties rendererProperties = screenItem.getBlockItemDisplayProperties().getItemRendererProperties();
header.append("<th ");
String alignment = "left";
String alignmentProperty = rendererProperties.getStringProperty("ALIGNMENT");
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals("JUSTIFY")) {
alignment = "justify";
} else if (alignmentProperty.equals("RIGHT")) {
alignment = "right";
} else if (alignmentProperty.equals("CENTER")) {
alignment = "center";
}
}
String valueVA = blockDisplayProperties.getBlockRendererProperties().getStringProperty(HEADER_VA);
if (valueVA != null && valueVA.length() > 0) {
styleClass = valueVA;
valueVA = rendererProperties.getStringProperty(HEADER_VA);
if (valueVA != null && valueVA.length() > 0)
styleClass = valueVA;
}
header.append(String.format(" class=\"%s\" ", styleClass));
if (alignment != null) {
header.append(String.format(" align=\'%s\'", alignment));
}
if (paddingStyle != null) {
header.append(String.format(" style=\'%s\'", paddingStyle));
}
header.append("> ");
header.append(screenItem.getLabel());
header.append("</th>");
}
}
final Browser browser = new Browser(layoutBody, SWT.NONE);
StringBuilder builder = new StringBuilder();
{
builder.append("<html>");
builder.append(getStyleDef(blockDisplayProperties.getEntireJProperties()));
builder.append("<div id=\"table\" style=\"float:left;width:100%;height:100%; overflow:auto\">");
{
EJDevBlockDisplayProperties blockProperties = blockDisplayProperties;
int cellSpacing = blockProperties.getBlockRendererProperties().getIntProperty(CELL_SPACING_PROPERTY, 0);
builder.append("<table border=0 cellspacing=").append(cellSpacing).append(" width=\"100%\" >");
{
int charHeight = (Display.getDefault().getSystemFont()).getFontData()[0].getHeight();
;
String trDef = String.format("<tr style=\"height: %spx\">", String.valueOf(charHeight));
if (addHeader) {
builder.append(header.toString());
}
int lastRowSpan = 0;
String oddVA = "default_all";
String valueVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_ODD_VA);
if (valueVA != null && valueVA.length() > 0) {
oddVA = valueVA;
}
String evenVA = "default_all";
valueVA = blockProperties.getBlockRendererProperties().getStringProperty(ROW_EVEN_VA);
if (valueVA != null && valueVA.length() > 0) {
evenVA = valueVA;
}
int rowid = 0;
for (int k = 0; k < 4; k++) {
rowid++;
if (lastRowSpan > 1) {
for (int i = 1; i < lastRowSpan; i++) {
builder.append(trDef).append("</tr>");
}
lastRowSpan = 0;
}
builder.append(trDef);
for (final EJDevScreenItemDisplayProperties item : displayProperties.getAllItemDisplayProperties()) {
String styleClass = (rowid % 2) != 0 ? oddVA : evenVA;
String alignment = null;
float width = -1;
EJFrameworkExtensionProperties rendererProperties = ((EJDevMainScreenItemDisplayProperties) item).getBlockRendererRequiredProperties();
builder.append(String.format("<td class=\"%s\" ", styleClass));
if (paddingStyle != null) {
builder.append(String.format(" style=\'%s\'", paddingStyle));
}
if (width == -1) {
width = rendererProperties.getIntProperty(DISPLAY_WIDTH_PROPERTY, 0);
}
if (width > 0) {
Font font = browser.getFont();
if (font != null) {
float avgCharWidth = getAvgCharWidth(font);
if (avgCharWidth > 0) {
if (width != 1) {
// add +1 padding
width = ((int) (((width + 1) * avgCharWidth)));
}
}
}
builder.append(String.format(" width=%s ", width));
}
if (alignment == null) {
String alignmentProperty = item.getBlockItemDisplayProperties().getItemRendererProperties().getStringProperty("ALIGNMENT");
alignment = "left";
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals("JUSTIFY")) {
alignment = "justify";
} else if (alignmentProperty.equals("RIGHT")) {
alignment = "right";
} else if (alignmentProperty.equals("CENTER")) {
alignment = "center";
}
}
}
if (alignment != null) {
builder.append(String.format(" align=\'%s\'", alignment));
}
builder.append(">");
// builder.append(String.format("<p class=\"default %s\">",
// styleClass));
String text = item.getReferencedItemName();
builder.append(text);
builder.append("</td>");
}
builder.append("</tr>");
}
}
builder.append("</table>");
}
builder.append("</<div>");
builder.append("</html>");
}
browser.setText(builder.toString());
}
return new EJDevBlockRendererDefinitionControl(blockDisplayProperties, Collections.<EJDevItemRendererDefinitionControl>emptyList());
}
Aggregations