use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTDateTimeItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
String hint = _screenItemProperties.getHint();
if (_displayValueAsLabel) {
labelField = new EJRWTAbstractLabel(composite) {
@Override
public Label createLabel(Composite parent) {
return _valueLabel = newVlaueLabel(parent);
}
@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;
}
};
_valueLabel.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_DATETIME);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_valueLabel.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
_valueLabel.setData(_itemProperties.getName());
if (hint != null && hint.trim().length() > 0) {
_valueLabel.setToolTipText(hint);
}
_visualContext = new EJRWTItemRendererVisualContext(_valueLabel.getBackground(), _valueLabel.getForeground(), _valueLabel.getFont());
setInitialValue(_baseValue);
} else {
_actionControl = new EJRWTAbstractActionDateTime(composite) {
private static final long serialVersionUID = 2592484612013403481L;
@Override
public DateTime createText(Composite parent) {
int style = SWT.BORDER;
String details = _rendererProps.getStringProperty(EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_DETAILS);
if (EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_DETAILS_LONG.equals(details)) {
style = style | SWT.LONG;
} else if (EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_DETAILS_MEDIUM.equals(details)) {
style = style | SWT.MEDIUM;
} else if (EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_DETAILS_SHORT.equals(details)) {
style = style | SWT.SHORT;
}
String type = _rendererProps.getStringProperty(EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_TYPE);
if (EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_TYPE_CALENDAR.equals(type)) {
style = style | SWT.CALENDAR;
} else if (EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_TYPE_DATE.equals(type)) {
style = style | SWT.DATE;
} else if (EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_TYPE_TIME.equals(type)) {
style = style | SWT.TIME;
}
if (_rendererProps.getBooleanProperty(EJRWTDateTimeItemRendererDefinitionProperties.PROPERTY_DROP_DOWN, false)) {
style = style | SWT.DROP_DOWN;
}
_textField = newTextField(parent, style);
_textField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_DATETIME);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
_textField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
valueChanged();
}
});
return _textField;
}
@Override
public Control createCustomActionLabel(Composite parent) {
return createCustomButtonControl(parent);
}
@Override
public Control createActionLabel(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setImage(EJRWTImageRetriever.get(EJRWTImageRetriever.IMG_FIND_LOV));
label.addFocusListener(EJRWTDateTimeItemRenderer.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) {
}
});
return label;
}
};
if (hint != null && hint.trim().length() > 0) {
_textField.setToolTipText(hint);
}
_visualContext = new EJRWTItemRendererVisualContext(_textField.getBackground(), _textField.getForeground(), _textField.getFont());
_textField.setData(_item.getReferencedItemProperties().getName());
_textField.addFocusListener(this);
String[] keys = new String[] { "BACKSPACE" };
_textField.setData(EJ_RWT.ACTIVE_KEYS, keys);
if ((_textField.getStyle() & SWT.TIME) != 0)
_textField.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
if (e.keyCode == SWT.BS) {
Date value = getValue();
if (value != null) {
_textField.setTime(0, 0, 0);
valueChanged();
}
}
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
}
});
_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();
setInitialValue(_baseValue);
}
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTImageItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
String alignmentProperty = _rendererProps.getStringProperty(EJRWTImageItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
String hint = _screenItemProperties.getHint();
int style = SWT.NONE;
style = getComponentStyle(alignmentProperty, style);
final String label = _screenItemProperties.getLabel();
final Label labelField = new Label(composite, style);
_labelField = labelField;
_labelField.setData(EJ_RWT.CUSTOM_VARIANT, EJ_RWT.CSS_CV_ITEM_IMAGE);
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_labelField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
_labelField.setText(label != null ? label : "");
_labelField.setToolTipText(hint != null ? hint : "");
_labelField.setData(_item.getReferencedItemProperties().getName());
_labelField.addFocusListener(this);
_visualContext = new EJRWTItemRendererVisualContext(_labelField.getBackground(), _labelField.getForeground(), _labelField.getFont());
_mandatoryDecoration = new ControlDecoration(_labelField, SWT.TOP | SWT.LEFT);
_errorDecoration = new ControlDecoration(_labelField, 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();
_labelField.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent arg0) {
if (_currentImage != null && !_currentImage.isDisposed()) {
_currentImage.dispose();
_currentImage = null;
}
}
});
String actionCommand = _screenItemProperties.getActionCommand();
if (actionCommand != null && actionCommand.trim().length() != 0) {
_labelField.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
_item.executeActionCommand();
}
});
}
});
}
_labelField.setImage(_defaultImage);
_mandatoryDecoration.hide();
setMessage(message);
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTStackedItemRenderer method refreshForeground.
private void refreshForeground() {
Color foreground = EJRWTVisualAttributeUtils.INSTANCE.getForeground(_visualAttributeProperties);
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.setForeground(foreground != null ? foreground : _visualContext.getForegroundColor());
}
}
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTStackedItemRenderer method refreshBackground.
private void refreshBackground() {
Color background = EJRWTVisualAttributeUtils.INSTANCE.getBackground(_visualAttributeProperties);
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.setBackground(background != null ? background : _visualContext.getBackgroundColor());
}
}
}
use of org.entirej.applicationframework.rwt.utils.EJRWTItemRendererVisualContext in project rap by entirej.
the class EJRWTCheckBoxItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
final String label = _screenItemProperties.getLabel();
final String hint = _screenItemProperties.getHint();
int style = SWT.NONE;
_button = newButton(composite, style = style | SWT.CHECK);
_button.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
if (_activeEvent) {
if (_useTriStateChaeckBox) {
if (!_button.getSelection()) {
_button.setGrayed(!_button.getGrayed());
if (_button.getGrayed()) {
_button.setSelection(true);
}
} else {
_button.setGrayed(false);
}
}
Object old = null;
Object newVal = null;
if (_button.getSelection()) {
old = _uncheckedValue;
newVal = _checkedValue;
} else {
old = _checkedValue;
newVal = _uncheckedValue;
}
EJ_RWT.setAttribute(_button, "ej-item-selection", String.valueOf(newVal));
_item.itemValueChaged(newVal);
_item.executeActionCommand();
}
}
});
if (label != null && label.trim().length() > 0) {
_button.setText(label);
}
if (hint != null && hint.trim().length() > 0) {
_button.setToolTipText(hint);
}
_button.setData(EJ_RWT.CUSTOM_VARIANT, 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);
}
_button.setData(_item.getReferencedItemProperties().getName());
_button.addFocusListener(this);
saveInitialVisualAttributePropeties();
_mandatoryDecoration = new ControlDecoration(_button, SWT.TOP | SWT.LEFT);
_errorDecoration = new ControlDecoration(_button, 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();
setInitialValue(_baseValue);
_visualContext = new EJRWTItemRendererVisualContext(_button.getBackground(), _button.getForeground(), _button.getFont());
EJ_RWT.setAttribute(_button, "ej-item-selection", String.valueOf(getValue()));
}
Aggregations