use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class ConfigureConnParamDialog method createTextComponent.
private void createTextComponent(final EConnectionParameterName key, IContext defaultContext) {
GridLayout gridLayout;
GridData gridData;
Composite hostComposite = new Composite(mainComposite, SWT.NONE);
gridLayout = new GridLayout();
gridLayout.verticalSpacing = 2;
gridLayout.marginTop = 5;
gridLayout.marginBottom = 2;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.marginLeft = 0;
gridLayout.marginRight = 0;
gridData = new GridData(GridData.FILL_HORIZONTAL);
hostComposite.setLayout(gridLayout);
hostComposite.setLayoutData(gridData);
Label hostLabel = new Label(hostComposite, SWT.NONE);
//$NON-NLS-1$
hostLabel.setText(key.getDisplayName() + ":");
GridData data = new GridData(GridData.FILL_HORIZONTAL);
// GridDataFactory.swtDefaults().hint(LABEL_DEFAULT_X, DEFAULT_HEIGHT).applyTo(hostLabel);
hostLabel.setLayoutData(data);
boolean isContext = ContextParameterUtils.isContainContextParam(pvValues.get(key));
int passStyle = SWT.BORDER;
if ((key == EConnectionParameterName.PASSWORD) && !isContext) {
passStyle = SWT.PASSWORD;
}
final Text host = new Text(hostComposite, passStyle);
host.setText(pvValues.get(key));
if (host.getText().trim().length() == 0) {
host.setBackground(ColorConstants.red);
host.redraw();
}
// GridDataFactory.swtDefaults().hint(TEXT_DEFAULT_X, DEFAULT_HEIGHT).applyTo(host);
gridData = new GridData(GridData.FILL_HORIZONTAL);
host.setLayoutData(gridData);
Composite contextComposite = new Composite(hostComposite, SWT.NULL);
GridLayout naviCommonCompLayout = new GridLayout(2, false);
naviCommonCompLayout.marginWidth = 0;
naviCommonCompLayout.marginHeight = 0;
contextComposite.setLayout(naviCommonCompLayout);
contextComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
contextComposite.setVisible(isContext);
final Text hostText = new Text(contextComposite, SWT.NONE);
hostText.setEditable(false);
gridData = new GridData();
hostText.setLayoutData(gridData);
hostText.setText(CONTEXT_WITH);
passStyle = SWT.NONE;
if (key == EConnectionParameterName.PASSWORD) {
passStyle = SWT.PASSWORD;
}
final Text hostValue = new Text(contextComposite, passStyle);
hostValue.setEditable(false);
gridData = new GridData(GridData.FILL_HORIZONTAL);
hostValue.setLayoutData(gridData);
hostValue.setText(ContextParameterUtils.parseScriptContextCode(host.getText(), defaultContext));
host.setData(TEXT_CONTROL, hostValue);
host.setData(key);
allParamText.add(host);
host.addKeyListener(new KeyAdapter() {
/*
* c (non-Javadoc)
*
* @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
*/
@Override
public void keyReleased(KeyEvent e) {
if (isRequriedValue(key.getName())) {
if (host.getText().trim().length() == 0) {
host.setBackground(ColorConstants.red);
host.redraw();
} else {
host.setBackground(ColorConstants.white);
host.redraw();
}
resetValues(host, hostValue);
}
}
});
}
use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class ToolbarSearchZone method addCommonsComponentListeners.
private void addCommonsComponentListeners() {
final SearchZoneMapper searchZoneMapper = new SearchZoneMapper(mapperManager);
searchText.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
// if change the search text ,need clear the data .
hightLightAllButton.setSelection(false);
searchZoneMapper.setHightlightAll(hightLightAllButton.getSelection());
if (searchMaps.size() > 0) {
searchZoneMapper.hightlightAll(searchMaps, false);
searchMaps.clear();
}
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
e.doit = false;
searchZoneMapper.search(searchMaps, searchText.getText());
selectKey = searchZoneMapper.selectHightlight(searchMaps, 0, "first");
}
}
public void keyReleased(KeyEvent e) {
}
});
downTableButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (searchMaps.isEmpty()) {
searchZoneMapper.search(searchMaps, searchText.getText());
}
if (selectKey + 1 < searchMaps.size()) {
if (!searchZoneMapper.isHightlightAll()) {
searchZoneMapper.hightlightAll(searchMaps, false);
} else {
searchZoneMapper.hightlightAll(searchMaps, true);
}
}
Integer selectKeyAtTableItem = searchZoneMapper.getSelectedKeyAtSelectedTableItem(searchMaps);
if (selectKeyAtTableItem > 0) {
selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKeyAtTableItem, "next");
} else if (selectKeyAtTableItem == 0 && selectKey == -1) {
selectKey = searchZoneMapper.selectHightlight(searchMaps, 0, "first");
} else {
selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKey, "next");
}
}
});
upTableButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (searchMaps.isEmpty()) {
searchZoneMapper.search(searchMaps, searchText.getText());
}
if (selectKey > 0) {
if (!searchZoneMapper.isHightlightAll()) {
searchZoneMapper.hightlightAll(searchMaps, false);
} else {
searchZoneMapper.hightlightAll(searchMaps, true);
}
}
Integer selectKeyAtTableItem = searchZoneMapper.getSelectedKeyAtSelectedTableItem(searchMaps);
if (selectKeyAtTableItem > 0) {
selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKeyAtTableItem, "previous");
} else if (selectKeyAtTableItem == 0 && selectKey == -1) {
selectKey = searchZoneMapper.selectHightlight(searchMaps, 0, "first");
} else {
selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKey, "previous");
}
}
});
hightLightAllButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (hightLightAllButton.getSelection()) {
searchMaps.clear();
searchZoneMapper.search(searchMaps, searchText.getText());
}
searchZoneMapper.setHightlightAll(hightLightAllButton.getSelection());
searchZoneMapper.hightlightAll(searchMaps, hightLightAllButton.getSelection());
}
});
}
use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class GenericSchemaForm method addFieldsListeners.
@Override
protected void addFieldsListeners() {
metadataNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
MetadataToolHelper.validateSchema(metadataNameText.getText());
metadataTable.setLabel(metadataNameText.getText());
checkFieldsValue();
}
});
metadataNameText.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
MetadataToolHelper.checkSchema(getShell(), e);
}
});
metadataCommentText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
metadataTable.setComment(metadataCommentText.getText());
}
});
tableEditorView.getMetadataEditor().addAfterOperationListListener(new IListenableListListener() {
@Override
public void handleEvent(ListenableListEvent event) {
checkFieldsValue();
}
});
}
use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class DataSetTableKeyListener method createPopup.
/**
* Display column finder popup.
*/
private void createPopup() {
plastNameSearched = null;
// recycle old popup
if (ppopup != null && !ppopup.isDisposed()) {
if (!ppopup.isVisible()) {
ppopup.open();
}
return;
}
// find out where to put the popup on screen
Point popupLocation = ptable.toDisplay(10, 40);
// create new shell
ppopup = new Shell(pparent.getShell(), SWT.BORDER | SWT.ON_TOP);
ppopup.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
ppopup.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
ppopup.setSize(250, 50);
ppopup.setLocation(popupLocation);
ppopup.setLayout(new GridLayout());
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
// add 'find:' label
Label label = new Label(ppopup, SWT.NULL);
//$NON-NLS-1$
label.setText(Messages.getString("DataSetTable.PopUp.Find"));
label.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
// add input field for search text
final Text input = new Text(ppopup, SWT.SINGLE | SWT.FILL);
input.setLayoutData(gridData);
input.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
// scroll columns whenever something is typed in input field.
input.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text t = (Text) e.widget;
String text = t.getText();
// locate column and show if found
if (jumpToColumn(text)) {
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
} else {
// give some subtle feedback to user that column doesn't exist..
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_RED));
}
}
});
// add listener so that we can jump to next column match when
// user hits enter..
input.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == ENTER) {
// scroll to next match
if (jumpToColumn(null)) {
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
} else {
// give some subtle feedback to user that column doesn't exist..
input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_RED));
}
}
}
});
// close popup when user is no longer in inputfield
input.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
disposePopup();
}
});
// activate popup
ppopup.open();
ppopup.forceActive();
}
use of org.eclipse.swt.events.KeyEvent in project tdi-studio-se by Talend.
the class StyledTextHandler method addListeners.
/**
* DOC amaumont Comment method "addListeners".
*/
private void addListeners() {
styledText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
refreshProposalSize();
}
public void focusLost(FocusEvent e) {
}
});
styledText.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
refreshProposalSize();
}
});
styledText.addExtendedModifyListener(new ExtendedModifyListener() {
public void modifyText(ExtendedModifyEvent event) {
// System.out.println("ExtendedModifyListener modify text");
updateCellExpression();
}
});
styledText.getContent().addTextChangeListener(new TextChangeListener() {
public void textChanged(TextChangedEvent event) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void textChanging(TextChangingEvent event) {
// System.out.println("textChanging");
}
public void textSet(TextChangedEvent event) {
// System.out.println("textSet");
}
});
styledText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
});
styledText.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
});
styledText.addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent verifyEvent) {
if (verifyEvent.character == '\r' && contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
verifyEvent.doit = false;
} else {
verifyEvent.doit = true;
}
}
});
styledText.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void mouseDown(MouseEvent e) {
mapperManager.fireCurrentDirectEditApply();
highlightLineOfCursorPosition(styledText.getSelection());
}
public void mouseUp(MouseEvent e) {
}
});
}
Aggregations