use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTListItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
_actionControl = new EJRWTAbstractActionList(composite) {
private static final long serialVersionUID = 2592484612013403481L;
@Override
protected boolean hasFilter() {
return _rendererProps.getBooleanProperty(FILTER, false);
}
@Override
public void refreshData() {
refreshList();
}
@Override
public org.eclipse.swt.widgets.List createList(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 | SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
style = getComponentStyle(alignmentProperty, style);
_listField = new org.eclipse.swt.widgets.List(parent, style);
_listField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LIST);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
String imageItem = _rendererProps.getStringProperty(COLUMN_IMAGE_ITEM);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_listField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
if (imageItem != null && imageItem.trim().length() > 0) {
_listField.setData(EJ_RWT.MARKUP_ENABLED, true);
}
if (hint != null && hint.trim().length() > 0) {
_listField.setToolTipText(hint);
}
_listField.setData(_item.getReferencedItemProperties().getName());
_listField.addFocusListener(EJRWTListItemRenderer.this);
_listField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (isValid()) {
Object old = _baseValue;
ListBoxValue value = getListBoxValue();
if (value != null && _activeEvent) {
value.populateReturnItems(_item.getBlock().getBlockController(), _item.getScreenType());
}
if (_activeEvent) {
_item.itemValueChaged(value.getItemValue());
}
setMandatoryBorder(_mandatory);
} else {
_isValid = true;
}
if (_activeEvent) {
_item.executeActionCommand();
}
}
});
return _listField;
}
@Override
public Control createActionLabel(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setImage(EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_FIND_LOV));
label.addFocusListener(EJRWTListItemRenderer.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 });
getListControl().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(_listField.getBackground(), _listField.getForeground(), _listField.getFont());
_mandatoryDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
_errorDecoration = new ControlDecoration(_actionControl, SWT.TOP | SWT.LEFT);
_errorDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_ERROR));
_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();
refreshList();
setInitialValue(_baseValue);
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTLabelItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
String alignmentProperty = _rendererProps.getStringProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
if (alignmentProperty == null) {
alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
}
boolean textWrapProperty = _rendererProps.getBooleanProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_TEXT_WRAP, false);
String hint = _screenItemProperties.getHint();
int style = SWT.NONE;
style = getComponentStyle(alignmentProperty, style);
if (textWrapProperty) {
style = style + SWT.WRAP;
}
_displayAsHyperlink = _rendererProps.getBooleanProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_DISPLAY_AS_HYPERLINK, false);
final String label = _screenItemProperties.getLabel();
if (!_displayAsHyperlink) {
final int labelStyle = style;
final EJRWTAbstractLabel labelField = new EJRWTAbstractLabel(composite) {
@Override
public Label createLabel(Composite parent) {
return new Label(parent, labelStyle);
}
@Override
public Control createCustomActionLabel(Composite parent) {
// TODO Auto-generated method stub
return null;
}
@Override
public Control createActionLabel(Composite parent) {
// TODO Auto-generated method stub
return null;
}
};
labelField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LABEL);
labelField.getLabelControl().setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LABEL);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
labelField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
labelField.getLabelControl().setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
// labelField.setData(EJ_RWT.MARKUP_ENABLED, _rendererProps.getBooleanProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_HTML_FORMAT, false));
labelField.getLabelControl().setData(EJ_RWT.MARKUP_ENABLED, _rendererProps.getBooleanProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_HTML_FORMAT, false));
String pictureName = _rendererProps.getStringProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_PICTURE);
if (pictureName != null && pictureName.length() > 0) {
if (pictureName != null && pictureName.trim().length() > 0) {
labelField.getLabelControl().setImage(EJRWTImageRetriever.get(pictureName));
}
}
labelField.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_item.executeActionCommand();
}
});
}
});
_labelField = new SWTComponentAdapter() {
@Override
public void setText(String text) {
if (controlState(labelField)) {
labelField.setText(text);
}
}
public void setFont(Font font) {
labelField.setFont(font);
}
@Override
public Font getFont() {
return labelField.getFont();
}
public void setForeground(Color color) {
labelField.setForeground(color);
}
@Override
public Color getForeground() {
return labelField.getForeground();
}
@Override
public String getText() {
return labelField.getText();
}
@Override
public Control getControl() {
return labelField;
}
};
} else {
final Link linkField;
final Control control;
// use workaround to make sure link also provide alignment
if (alignmentProperty != null && alignmentProperty.trim().length() > 0) {
if (alignmentProperty.equals(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_ALIGNMENT_LEFT)) {
control = linkField = new Link(composite, style);
} else if (alignmentProperty.equals(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_ALIGNMENT_RIGHT)) {
EJRWTEntireJGridPane sub = new EJRWTEntireJGridPane(composite, 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(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_ALIGNMENT_CENTER)) {
EJRWTEntireJGridPane sub = new EJRWTEntireJGridPane(composite, 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(composite, style);
}
} else {
control = linkField = new Link(composite, style);
}
linkField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LABEL);
_labelField = new SWTComponentAdapter() {
String value;
@Override
public void setText(String text) {
if (controlState(linkField)) {
linkField.setText(String.format("<a>%s</a>", value = text));
}
}
@Override
public void setFont(Font font) {
if (controlState(linkField)) {
linkField.setFont(font);
}
}
@Override
public Font getFont() {
if (controlState(linkField)) {
return linkField.getFont();
}
return null;
}
@Override
public void setForeground(Color color) {
if (controlState(linkField)) {
linkField.setForeground(color);
}
}
@Override
public Color getForeground() {
if (controlState(linkField)) {
return linkField.getForeground();
}
return null;
}
@Override
public String getText() {
return value;
}
@Override
public Control getControl() {
return control;
}
};
linkField.setData(EJ_RWT.MARKUP_ENABLED, _rendererProps.getBooleanProperty(EJRWTLabelItemRendererDefinitionProperties.PROPERTY_HTML_FORMAT, false));
linkField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_item.executeActionCommand();
}
});
}
});
}
_labelField.setText(label != null ? label : "");
_labelField.getControl().setToolTipText(hint != null ? hint : "");
_labelField.getControl().setData(_item.getReferencedItemProperties().getName());
_labelField.getControl().addFocusListener(this);
_visualContext = new EJRWTItemRendererVisualContext(_labelField.getControl().getBackground(), _labelField.getForeground(), _labelField.getControl().getFont());
_mandatoryDecoration = new ControlDecoration(_labelField.getControl(), SWT.TOP | SWT.LEFT);
_errorDecoration = new ControlDecoration(_labelField.getControl(), SWT.TOP | SWT.LEFT);
_errorDecoration.setImage(getDecorationImage(FieldDecorationRegistry.DEC_ERROR));
_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()));
_errorDecoration.hide();
_mandatoryDecoration.hide();
setMessage(message);
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTStackedItemRenderer method buildStackUI.
protected void buildStackUI(EJRWTEntireJStackedPane stackedPane) {
// create stack UI for eash type
// EJStackedItemRendererType.LABEL;
{
final Label label = new Label(stackedPane, SWT.NONE);
label.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LABEL);
label.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_LABEL);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
label.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
stackedPane.add(EJRWTStackedItemRendererType.LABEL.name(), new EJRWTEntireJStackedPane.StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.LABEL.name();
}
@Override
public Control getControl() {
return label;
}
});
label.setData(_item.getReferencedItemProperties().getName());
label.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(label.getBackground(), label.getForeground(), label.getFont()));
}
{
int style = SWT.NONE;
final Button _button = new Button(stackedPane, style = style | SWT.CHECK);
_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Object old = null;
Object newVal = null;
EJRWTStackedItemRendererConfig.CheckBox config = (CheckBox) _baseValue.getConfig();
if (_button.getSelection()) {
old = config.getCheckBoxUnCheckedValue();
newVal = config.getCheckBoxCheckedValue();
} else {
old = config.getCheckBoxCheckedValue();
newVal = config.getCheckBoxUnCheckedValue();
}
_item.executeActionCommand();
_item.itemValueChaged(getRealValue());
}
});
}
});
_button.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_CHECKBOX);
_button.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_CHECKBOX);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_button.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
stackedPane.add(EJRWTStackedItemRendererType.CHECKBOX.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.CHECKBOX.name();
}
@Override
public Control getControl() {
return _button;
}
});
_button.setData(_item.getReferencedItemProperties().getName());
_button.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(_button.getBackground(), _button.getForeground(), _button.getFont()));
}
{
int style = SWT.NONE;
final Button _button = new Button(stackedPane, style);
_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_item.executeActionCommand();
}
});
}
});
_button.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_BUTTON);
_button.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_BUTTON);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_button.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
stackedPane.add(EJRWTStackedItemRendererType.BUTTON.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.BUTTON.name();
}
@Override
public Control getControl() {
return _button;
}
});
_button.setData(_item.getReferencedItemProperties().getName());
_button.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(_button.getBackground(), _button.getForeground(), _button.getFont()));
}
{
int style = SWT.READ_ONLY;
final Combo _comboField = new Combo(stackedPane, style);
final ComboViewer _comboViewer = new ComboViewer(_comboField);
_comboField.setData(_item.getReferencedItemProperties().getName());
_comboField.addFocusListener(EJRWTStackedItemRenderer.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() {
private ComboBoxValue getComboBoxValue() {
if (controlState(_comboField)) {
IStructuredSelection selection = (IStructuredSelection) _comboViewer.getSelection();
return (ComboBoxValue) selection.getFirstElement();
}
return null;
}
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (!_modifyListener.enable) {
return;
}
if (isValid()) {
Object old = _baseValue.getValue();
ComboBoxValue value = getComboBoxValue();
if (value != null) {
value.populateReturnItems(_item.getBlock().getBlockController(), _item.getScreenType());
}
_item.itemValueChaged(getRealValue());
setMandatoryBorder(_mandatory);
} else {
_isValid = true;
}
_item.executeActionCommand();
}
});
_comboField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_COMBOBOX);
_comboField.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", 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);
}
stackedPane.add(EJRWTStackedItemRendererType.COMBO.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.COMBO.name();
}
@Override
public Control getControl() {
return _comboField;
}
});
_comboField.setData(_item.getReferencedItemProperties().getName());
_comboField.setData("VIEW", _comboViewer);
_comboField.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(_comboField.getBackground(), _comboField.getForeground(), _comboField.getFont()));
}
// EJStackedItemRendererType.SPACER;
{
final Label label = new Label(stackedPane, SWT.NONE);
// label.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_LABEL);
// label.setData(EJ_RWT.CUSTOM_VARIANT+"_DEF",
// EJ_RWT.CSS_CV_ITEM_LABEL);
// String customCSSKey =
// _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
//
// if (customCSSKey != null && customCSSKey.trim().length() > 0)
// {
// label.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
// }
stackedPane.add(EJRWTStackedItemRendererType.SPACER.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.SPACER.name();
}
@Override
public Control getControl() {
return label;
}
});
label.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(label.getBackground(), label.getForeground(), label.getFont()));
}
// EJStackedItemRendererType.TEXT;
{
final Text textField = new Text(stackedPane, SWT.BORDER);
connectLOVAction(textField);
textField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_TEXT);
textField.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_TEXT);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
textField.setData(_item.getReferencedItemProperties().getName());
textField.addFocusListener(this);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
textField.addModifyListener(_modifyListener);
stackedPane.add(EJRWTStackedItemRendererType.TEXT.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.TEXT.name();
}
@Override
public Control getControl() {
return textField;
}
});
textField.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(textField.getBackground(), textField.getForeground(), textField.getFont()));
}
// EJStackedItemRendererType.TEXT;
{
final Text textField = new Text(stackedPane, SWT.BORDER | SWT.MULTI | SWT.WRAP);
connectLOVAction(textField);
textField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_TEXTAREA);
textField.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_TEXTAREA);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
textField.setData(_item.getReferencedItemProperties().getName());
textField.addFocusListener(this);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
textField.addModifyListener(_modifyListener);
stackedPane.add(EJRWTStackedItemRendererType.TEXT_AREA.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.TEXT_AREA.name();
}
@Override
public Control getControl() {
return textField;
}
});
textField.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(textField.getBackground(), textField.getForeground(), textField.getFont()));
}
// EJStackedItemRendererType.NUMBER;
{
final Text textField = new Text(stackedPane, SWT.BORDER | SWT.RIGHT);
textField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_NUMBER);
textField.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_NUMBER);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
textField.setData(_item.getReferencedItemProperties().getName());
textField.addFocusListener(this);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
textField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
if (textField.getText().trim().length() > 0) {
try {
_decimalFormatter.parse(textField.getText());
_errorDecoration.hide();
} catch (ParseException e) {
_rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_FORMAT);
_errorDecoration.setDescriptionText(String.format("Invalid Number format. Should be %s ", _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_FORMAT)));
_errorDecoration.show();
}
}
}
});
connectLOVAction(textField);
textField.addModifyListener(_modifyListener);
textField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent arg0) {
try {
_modifyListener.enable = false;
Object value = getValue();
if (value != null && _baseValue.getValue() != null) {
textField.setText(_decimalFormatter.format(_baseValue.getValue()));
} else {
textField.setText("");
}
} finally {
_modifyListener.enable = true;
}
}
@Override
public void focusGained(FocusEvent arg0) {
}
});
stackedPane.add(EJRWTStackedItemRendererType.NUMBER.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.NUMBER.name();
}
@Override
public Control getControl() {
return textField;
}
});
textField.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(textField.getBackground(), textField.getForeground(), textField.getFont()));
}
// EJStackedItemRendererType.DATE;
{
final Text textField = new Text(stackedPane, SWT.BORDER | SWT.RIGHT);
textField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_DATE);
textField.setData(EJ_RWT.CUSTOM_VARIANT + "_DEF", EJ_RWT.CSS_CV_ITEM_DATE);
textField.setData(_item.getReferencedItemProperties().getName());
textField.addFocusListener(this);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
connectLOVAction(textField);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
textField.addModifyListener(_modifyListener);
textField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
if (textField.getText().trim().length() > 0) {
try {
_dateFormat.parse(textField.getText());
_errorDecoration.hide();
} catch (ParseException e) {
String format = _dateFormat.toFormatString();
if (format == null || format.length() == 0) {
format = "eg: " + _dateFormat.format(new Date());
}
_errorDecoration.setDescriptionText(String.format("Invalid Date format. Should be %s ", format));
_errorDecoration.show();
}
}
}
});
textField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent arg0) {
try {
_modifyListener.enable = false;
Object value = getValue();
if (value != null && _baseValue.getValue() != null) {
textField.setText(_dateFormat.format(_baseValue.getValue()));
} else {
textField.setText("");
}
} finally {
_modifyListener.enable = true;
}
}
@Override
public void focusGained(FocusEvent arg0) {
}
});
stackedPane.add(EJRWTStackedItemRendererType.DATE.name(), new StackedPage() {
@Override
public String getKey() {
return EJRWTStackedItemRendererType.DATE.name();
}
@Override
public Control getControl() {
return textField;
}
});
textField.setData("EJRWTItemRendererVisualContext", new EJRWTItemRendererVisualContext(textField.getBackground(), textField.getForeground(), textField.getFont()));
}
{
}
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTStackedItemRenderer method refreshFont.
private void refreshFont() {
EJRWTStackedItemRendererType[] values = EJRWTStackedItemRendererType.values();
for (EJRWTStackedItemRendererType type : values) {
Control control = stackedPane.getControl(type.name());
if (control != null && controlState(control)) {
EJRWTItemRendererVisualContext _visualContext = (EJRWTItemRendererVisualContext) control.getData("EJRWTItemRendererVisualContext");
control.setFont(EJRWTVisualAttributeUtils.INSTANCE.getFont(_visualAttributeProperties, _visualContext.getItemFont()));
}
}
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTButtonItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
String pictureName = _itemProperties.getItemRendererProperties().getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_PICTURE);
String alignmentProperty = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
if (alignmentProperty == null) {
alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
}
String hint = _screenItemProperties.getHint();
String label = _screenItemProperties.getLabel();
int style = SWT.PUSH;
style = getComponentStyle(alignmentProperty, style);
_button = newButton(composite, style);
setHint(hint);
setLabel(label);
if (pictureName != null && pictureName.trim().length() > 0) {
_button.setImage(EJRWTImageRetriever.get(pictureName));
}
_button.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_BUTTON);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_button.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
_button.setData(_item.getReferencedItemProperties().getName());
_button.addFocusListener(this);
_button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (_activeEvent) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_item.executeActionCommand();
}
});
}
}
});
if (_rendererProps.getBooleanProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_DEFAULT_BUTTON, false)) {
Shell shell = composite.getShell();
if (shell != null) {
shell.setDefaultButton(_button);
}
}
_errorDecoration = new ControlDecoration(_button, SWT.TOP | SWT.LEFT);
setMessage(message);
_visualContext = new EJRWTItemRendererVisualContext(_button.getBackground(), _button.getForeground(), _button.getFont());
}
Aggregations