use of org.eclipse.swt.events.MouseListener in project tdi-studio-se by Talend.
the class ImportComponentDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout gl = new GridLayout(5, true);
composite.setLayout(gl);
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 5;
label.setLayoutData(data);
label.setFont(parent.getFont());
}
Label label1 = new Label(composite, SWT.NONE);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 2;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
text = new Text(composite, SWT.BORDER);
text.setEditable(false);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
if (paletteComponentsPath == null) {
//$NON-NLS-1$
paletteComponentsPath = "";
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(true);
}
});
Button button = new Button(composite, SWT.NONE);
//$NON-NLS-1$
button.setText(Messages.getString("ImportComponentDialog.Browser"));
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 1;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
String path = dd.open();
if (path != null) {
text.setText(path);
}
}
});
Button showPaletteComponents = new Button(composite, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
showPaletteComponents.setLayoutData(gd);
//$NON-NLS-1$
showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
showPaletteComponents.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText(paletteComponentsPath);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 1;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.Filter"));
filterText = new Text(composite, SWT.BORDER);
filterText.setEditable(true);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
filterText.setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(false);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
componentList.setLayoutData(gd);
componentList.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
validateSelected();
}
public void mouseUp(MouseEvent e) {
validateSelected();
}
});
errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
errorMessageText.setLayoutData(gd);
errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
applyDialogFont(composite);
//$NON-NLS-1$
text.setText("");
return composite;
}
use of org.eclipse.swt.events.MouseListener in project tdi-studio-se by Talend.
the class DataMapTableView method attachCellExpressionToStyledTextEditor.
/**
* DOC amaumont Comment method "attachCellExpressionToStyledTextEditor".
*
* @param tableViewerCreator TODO
* @param styledTextHandler
* @param expressionEditorText2
*/
protected void attachCellExpressionToStyledTextEditor(final TableViewerCreator tableViewerCreator, final Text expressionTextEditor, final StyledTextHandler styledTextHandler) {
expressionTextEditor.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
styledTextHandler.setCurrentEntry(currentModifiedEntry);
Text text = (Text) e.widget;
if (Math.abs(text.getText().length() - styledTextHandler.getStyledText().getText().length()) > 1) {
styledTextHandler.setTextWithoutNotifyListeners(text.getText());
// highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
}
});
expressionTextEditor.addKeyListener(new KeyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
*/
@Override
public void keyPressed(KeyEvent e) {
// System.out.println("e.character=" + e.character);
// System.out.println("keyCode=" + e.keyCode);
boolean ctrl = (e.stateMask & SWT.CTRL) != 0;
boolean altgr = (e.stateMask & SWT.ALT) != 0;
if (e.character == '\0' || ctrl && !altgr) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
} else {
UnnotifiableColorStyledText mapperColorStyledText = (UnnotifiableColorStyledText) styledTextHandler.getStyledText();
Point selection = expressionTextEditor.getSelection();
if (e.character == '\r' || e.character == '') {
e.doit = false;
styledTextHandler.setTextWithoutNotifyListeners(expressionTextEditor.getText());
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
} else {
if (e.character == SWT.BS || e.character == SWT.DEL) {
if (selection.x == selection.y) {
if (e.character == SWT.BS) {
if (selection.x - 1 > 0 && mapperColorStyledText.getText().length() > selection.x - 1) {
char previousChar = mapperColorStyledText.getText().charAt(selection.x - 1);
if (previousChar == '\n') {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 2, 2, "");
} else {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 1, 1, "");
}
}
} else {
if (selection.x < mapperColorStyledText.getText().length()) {
char nextChar = mapperColorStyledText.getText().charAt(selection.x);
if (nextChar == '\r') {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 2, "");
} else {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 1, "");
}
}
}
} else {
if (selection.y <= mapperColorStyledText.getCharCount()) {
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, //$NON-NLS-1$
"");
}
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
} else {
// System.out.println("mapperColorStyledText.getText()="+mapperColorStyledText.getText().length());
if (selection.y <= mapperColorStyledText.getCharCount()) {
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, String.valueOf(e.character));
}
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
}
}
}
@Override
public void keyReleased(KeyEvent e) {
// highlightLineOfCursorPosition();
}
});
expressionTextEditor.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
@Override
public void mouseDown(MouseEvent e) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
@Override
public void mouseUp(MouseEvent e) {
}
});
}
use of org.eclipse.swt.events.MouseListener in project tdi-studio-se by Talend.
the class SQLPatternComposite method createCodeControl.
/**
* DOC bqian Comment method "createCodeControl".
*
* @param panel
* @param
*/
private void createCodeControl(Composite panel, Control reference) {
codeText = new Text(panel, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
codeText.setEditable(false);
FormData fd = new FormData();
fd.left = new FormAttachment(10, 0);
fd.right = new FormAttachment(90, 0);
fd.top = new FormAttachment(reference, 2);
fd.bottom = new FormAttachment(95, 0);
codeText.setLayoutData(fd);
codeText.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
if (tableViewer.getTable().getSelection().length == 0) {
return;
}
TableItem item = tableViewer.getTable().getSelection()[0];
if (item == null || item.getText() == null) {
return;
}
String sqlpatternName = item.getText();
SQLPatternItem patternItem = SQLPatternUtils.getSQLPatternItem(SQLPatternComposite.this.element, sqlpatternName);
if (patternItem.isSystem()) {
boolean answer = //$NON-NLS-1$
MessageDialog.openQuestion(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.TOS"), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.forbidModification"));
if (!answer) {
return;
}
IRepositoryService repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IElementParameter parameter = element.getElementParameter(EParameterName.SQLPATTERN_DB_NAME.getName());
String dbName = (String) parameter.getValue();
//$NON-NLS-1$
String path = dbName + "/" + RepositoryConstants.USER_DEFINED;
repositoryService.createSqlpattern(path, true);
} else if (sqlPatternAndProject.get(patternItem) != null) {
MessageDialog.openInformation(getShell(), "Information", "Forbid modification on sql template from reference project");
} else {
boolean answer = //$NON-NLS-1$
MessageDialog.openQuestion(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.TOS"), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.modifySQLPattern"));
if (!answer) {
return;
}
IRepositoryService repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
repositoryService.openSQLPatternEditor(patternItem, false);
}
}
@Override
public void mouseDown(MouseEvent e) {
// do nothing
}
@Override
public void mouseDoubleClick(MouseEvent e) {
mouseUp(e);
}
});
}
use of org.eclipse.swt.events.MouseListener 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) {
highlightLineOfCursorPosition(styledText.getSelection());
}
public void mouseUp(MouseEvent e) {
}
});
}
use of org.eclipse.swt.events.MouseListener in project cubrid-manager by CUBRID.
the class QueryExecuter method bindEvents.
private void bindEvents() {
selectableSupport.getTableCursor().addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
performEdit();
}
});
selectableSupport.getTableCursor().addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
if (e.character == SWT.CR) {
performEdit();
}
}
});
selectableSupport.getTableCursor().addKeyListener(new org.eclipse.swt.events.KeyAdapter() {
public void keyReleased(KeyEvent event) {
if (isEditMode() && event.keyCode == SWT.DEL) {
deleteRecord(tblResult, null);
} else if (((event.stateMask & SWT.CTRL) != 0 || (event.stateMask & SWT.COMMAND) != 0) && (event.keyCode == 'c' || event.character == '')) {
// key press 'ctrl + c' is intercept by editor text so add
// here
copySelectedItems();
} else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'a') {
selectableSupport.selectAll();
}
}
});
}
Aggregations