use of org.eclipse.swt.events.KeyListener 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.eclipse.swt.events.KeyListener in project rap by entirej.
the class EJRWTTextItemRenderer method createComponent.
@Override
public void createComponent(Composite composite) {
String alignmentProperty = _rendererProps.getStringProperty(EJRWTTextItemRendererDefinitionProperties.PROPERTY_ALIGNMENT);
if (alignmentProperty == null) {
alignmentProperty = _rendererProps.getStringProperty("ALLIGNMENT");
}
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(_itemProperties.getName());
_valueLabel.setData(EJ_RWT.CUSTOM_VARIANT, getCSSKey());
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_valueLabel.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
if (hint != null && hint.trim().length() > 0) {
_valueLabel.setToolTipText(hint);
}
setValueLabelAlign(alignmentProperty);
_visualContext = new EJRWTItemRendererVisualContext(_valueLabel.getBackground(), _valueLabel.getForeground(), _valueLabel.getFont());
setInitialValue(_baseValue);
} else {
final String alignmentProp = alignmentProperty;
_actionControl = new EJRWTAbstractActionText(composite) {
@Override
public Text createText(Composite parent) {
int style = SWT.BORDER;
if (_displayValueAsProtected) {
style = style | SWT.PASSWORD;
}
_textField = newTextField(parent, getComponentStyle(alignmentProp, style));
_textField.setData(EJ_RWT.CUSTOM_VARIANT, getCSSKey());
String customCSSKey = _rendererProps.getStringProperty(EJRWTButtonItemRendererDefinitionProperties.PROPERTY_CSS_KEY);
if (customCSSKey != null && customCSSKey.trim().length() > 0) {
_textField.setData(EJ_RWT.CUSTOM_VARIANT, customCSSKey);
}
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(EJRWTTextItemRenderer.this);
label.addMouseListener(new MouseListener() {
private static final long serialVersionUID = 529634857284996692L;
@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";
}
String[] keys = new String[] { lovKey, "ENTER", "RETURN", "CR" };
label.setData(EJ_RWT.ACTIVE_KEYS, keys);
getTextControl().setData(EJ_RWT.ACTIVE_KEYS, keys);
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);
}
if (arg0.keyCode == 13 && (SWT.MULTI != (_textField.getStyle() & SWT.MULTI) || (arg0.stateMask & SWT.CONTROL) != 0)) {
commitValue();
}
}
@Override
public void keyPressed(KeyEvent arg0) {
}
});
return label;
}
};
if (_maxLength > 0) {
_textField.setTextLimit(_maxLength);
}
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);
_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();
_textField.addModifyListener(_modifyListener);
// TODO: Move to client side validation on Rap 2.4
if (_valueCase != null && _valueCase != VALUE_CASE.DEFAULT) {
_textField.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent event) {
String caseValue = toCaseValue(event.text);
if (!event.text.equals(caseValue)) {
event.text = caseValue;
}
}
});
}
setInitialValue(_baseValue);
_textField.setMessage(defaultMessage == null ? "" : defaultMessage);
setMessage(message);
}
}
use of org.eclipse.swt.events.KeyListener in project jbosstools-hibernate by jbosstools.
the class AddPropertyDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
String dialogTitle = HibernateConsoleMessages.AddPropertyDialog_add_exporter_property;
String editTitle = HibernateConsoleMessages.AddPropertyDialog_add_property_to;
if (flagEdit) {
dialogTitle = HibernateConsoleMessages.AddPropertyDialog_edit_exporter_property;
editTitle = HibernateConsoleMessages.AddPropertyDialog_edit_property_to;
}
getShell().setText(dialogTitle);
setTitle(editTitle + ef.getExporterDefinition().getDescription());
Composite control = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(control, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
Label label = new Label(composite, SWT.NONE);
label.setText(HibernateConsoleMessages.AddPropertyDialog_name);
final Combo combo = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN);
GridData pgd = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
pgd.horizontalSpan = 2;
combo.setLayoutData(pgd);
combo.setFocus();
combo.addModifyListener(modifyListener);
propertyCombo = new ComboViewer(combo);
combo.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.ARROW_DOWN) {
// linux doesn't call selectionChanged event on this events
propertyCombo.setSelection(propertyCombo.getSelection(), false);
return;
}
for (int i = 0; i < combo.getItemCount(); i++) {
if (combo.getText().equals(combo.getItem(i))) {
if (combo.getSelectionIndex() != i) {
combo.select(i);
propertyCombo.setSelection(propertyCombo.getSelection(), false);
}
return;
}
}
disposeBrowseButton();
createTextValueComposite(2);
}
});
if (flagEdit) {
propertyCombo.getControl().setEnabled(false);
}
label = new Label(composite, SWT.NONE);
label.setText(HibernateConsoleMessages.AddPropertyDialog_value);
value = new Text(composite, SWT.BORDER);
value.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
((Text) value).addModifyListener(modifyListener);
initDefaultNames(ef, propertyCombo);
return control;
}
use of org.eclipse.swt.events.KeyListener in project arduino-eclipse-plugin by Sloeber.
the class Import_Source_Folder_Page method createSourceGroup.
@Override
protected void createSourceGroup(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout theGridLayout = new GridLayout();
GridData theGriddata;
theGridLayout.numColumns = 3;
composite.setLayout(theGridLayout);
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
composite.setFont(parent.getFont());
Label line = new Label(composite, SWT.HORIZONTAL | SWT.BOLD);
line.setText(Messages.ui_select_folder);
theGriddata = new GridData(SWT.FILL, SWT.CENTER, true, false);
theGriddata.horizontalSpan = 3;
line.setLayoutData(theGriddata);
Label TheLabel = new Label(composite, SWT.NONE);
// $NON-NLS-1$
TheLabel.setText("Source Folder Location:");
theGriddata = new GridData();
theGriddata.horizontalAlignment = SWT.LEFT;
theGriddata.horizontalSpan = 1;
theGriddata.grabExcessHorizontalSpace = false;
TheLabel.setLayoutData(theGriddata);
this.controlLibraryPath = new Text(composite, SWT.SINGLE | SWT.BORDER);
theGriddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
theGriddata.widthHint = SIZING_TEXT_FIELD_WIDTH;
// theGriddata.horizontalSpan = 1;
this.controlLibraryPath.setLayoutData(theGriddata);
this.controlLibraryPath.addKeyListener(new KeyListener() {
@SuppressWarnings("synthetic-access")
@Override
public void keyReleased(KeyEvent e) {
updateWidgetEnablements();
}
@Override
public void keyPressed(KeyEvent e) {
// nothing to do here
}
});
this.controlBrowseButton = new Button(composite, SWT.NONE);
// $NON-NLS-1$
this.controlBrowseButton.setText("Browse...");
theGriddata = new GridData();
theGriddata.horizontalSpan = 1;
theGriddata.horizontalAlignment = SWT.LEAD;
theGriddata.grabExcessHorizontalSpace = false;
this.controlBrowseButton.setLayoutData(theGriddata);
this.controlBrowseButton.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("synthetic-access")
@Override
public void widgetSelected(SelectionEvent event) {
final Shell shell = new Shell();
DirectoryDialog theDialog = new DirectoryDialog(shell);
if ((Import_Source_Folder_Page.this.controlLibraryPath.getText() == null) || (Import_Source_Folder_Page.this.controlLibraryPath.getText() == EMPTY_STRING)) {
theDialog.setFilterPath(Import_Source_Folder_Page.this.controlLibraryPath.getText());
}
String Path = theDialog.open();
if (Path != null) {
Import_Source_Folder_Page.this.controlLibraryPath.setText(Path);
updateWidgetEnablements();
}
}
});
line = new Label(composite, SWT.HORIZONTAL | SWT.BOLD);
line.setText(Messages.ui_import_subfolder_to_import_to);
theGriddata = new GridData(SWT.FILL, SWT.CENTER, true, false);
theGriddata.horizontalSpan = 3;
line.setLayoutData(theGriddata);
}
Aggregations