use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class MapperUI method addParentListeners.
private void addParentListeners(final UIManager uiManager, final ExternalDbMapUiProperties uiProperties) {
mapperUIParent.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
release();
}
});
mapperUIParent.addListener(SWT.Close, new Listener() {
public void handleEvent(Event event) {
if (uiManager.getMapperResponse() == SWT.NONE) {
uiManager.setMapperResponse(SWT.CANCEL);
}
}
});
mapperUIParent.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
updateBackground(false, true);
}
public void focusLost(FocusEvent e) {
}
});
// store size if not maximized
if (mapperUIParent instanceof Shell) {
((Shell) mapperUIParent).addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
if (!((Shell) e.getSource()).getMaximized()) {
uiProperties.setBoundsMapper(((Shell) e.getSource()).getBounds());
}
}
});
}
}
use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class MapperUI method addKeyListener.
private void addKeyListener(final UIManager uiManager, final Display display) {
Listener listener = new Listener() {
public void handleEvent(Event event) {
if (event.type == SWT.KeyUp || event.type == SWT.KeyDown) {
boolean isPressed = event.type == SWT.KeyDown ? true : false;
if (event.keyCode == SWT.CTRL) {
uiManager.setCtrlPressed(isPressed);
// System.out.println("+++++ Ctrl : " + isPressed);
}
if (event.keyCode == SWT.SHIFT) {
uiManager.setShiftPressed(isPressed);
// System.out.println("+++++ Shift : "+ isPressed);
}
}
// System.out.println(event.stateMask);
}
};
display.addFilter(SWT.KeyUp, listener);
display.addFilter(SWT.KeyDown, listener);
// display.addFilter(SWT.Move, listener);
// display.addFilter(SWT.MouseMove, listener);
// display.addFilter(SWT.HardKeyDown, listener);
// display.addFilter(SWT.HardKeyUp, listener);
// display.addFilter(SWT.None, listener);
// display.addFilter(SWT.DragDetect, listener);
// display.addFilter(SWT.Paint, listener);
// display.addListener(SWT.KeyUp, listener);
// display.addListener(SWT.KeyDown, listener);
// display.addListener(SWT.Move, listener);
// display.addListener(SWT.MouseMove, listener);
// display.addListener(SWT.HardKeyDown, listener);
// display.addListener(SWT.HardKeyUp, listener);
// display.addListener(SWT.None, listener);
// display.addListener(SWT.DragDetect, listener);
// display.addListener(SWT.Paint, listener);
}
use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class JSONFileStep2Form method addGroupSchemaTarget.
private void addGroupSchemaTarget(final Composite mainComposite, final int width, final int height) {
// Group Schema Viewer
schemaTargetGroup = Form.createGroup(mainComposite, 1, "Target Schema", height);
// to correct graphic bug under Linux-GTK when the wizard is opened the first time
if (WindowSystem.isGTK() && firstTimeWizardOpened.equals(Boolean.TRUE)) {
schemaTargetGroup.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
Point offsetPoint = event.display.map(linker.getBgDrawableComposite(), schemaTargetGroup, new Point(0, 0));
linker.setOffset(offsetPoint);
linker.drawBackground(event.gc);
}
});
}
// ///////////////////////////////////////////
schemaTargetGroup.setBackgroundMode(SWT.INHERIT_FORCE);
CommandStackForComposite commandStack = new CommandStackForComposite(schemaTargetGroup);
loopModel = new JSONExtractorLoopModel("Path loop expression");
loopTableEditorView = new ExtractionLoopWithJSONXPathEditorView(loopModel, schemaTargetGroup);
loopTableEditorView.getExtendedTableViewer().setCommandStack(commandStack);
GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
data2.heightHint = 90;
final Composite loopTableEditorComposite = loopTableEditorView.getMainComposite();
loopTableEditorComposite.setLayoutData(data2);
loopTableEditorComposite.setBackground(null);
// to correct graphic bug under Linux-GTK when the wizard is opened the first time
if (WindowSystem.isGTK() && firstTimeWizardOpened.equals(Boolean.TRUE)) {
loopTableEditorComposite.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
Point offsetPoint = event.display.map(linker.getBgDrawableComposite(), loopTableEditorComposite, new Point(0, 0));
linker.setOffset(offsetPoint);
linker.drawBackground(event.gc);
}
});
}
// ///////////////////////////////////////////
// Messages.getString("FileStep3.metadataDescription")
fieldsModel = new JSONExtractorFieldModel("Fields to extract");
fieldsTableEditorView = new ExtractionFieldsWithJSONXPathEditorView(fieldsModel, schemaTargetGroup);
fieldsTableEditorView.getExtendedTableViewer().setCommandStack(commandStack);
final Composite fieldTableEditorComposite = fieldsTableEditorView.getMainComposite();
data2 = new GridData(GridData.FILL_BOTH);
data2.heightHint = 180;
fieldTableEditorComposite.setLayoutData(data2);
fieldTableEditorComposite.setBackground(null);
// to correct graphic bug under Linux-GTK when the wizard is opened the first time
if (WindowSystem.isGTK() && firstTimeWizardOpened.equals(Boolean.TRUE)) {
fieldTableEditorComposite.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
Point offsetPoint = event.display.map(linker.getBgDrawableComposite(), fieldTableEditorComposite, new Point(0, 0));
linker.setOffset(offsetPoint);
linker.drawBackground(event.gc);
}
});
}
// ///////////////////////////////////////////
}
use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class AbstractTreeNodeButton method init.
private void init(Composite parent, String tooltip, Image image) {
button = new Button(parent, SWT.PUSH);
button.setToolTipText(tooltip);
button.setImage(image);
button.setEnabled(false);
button.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (treeViewer != null && !treeViewer.getTree().isDisposed() && treeViewer.getSelection() instanceof ITreeSelection) {
handleSelectionEvent((TreeSelection) treeViewer.getSelection());
}
}
});
treeViewer = form.getTreeViewer();
addTreeListeners();
}
use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class MergeOrderDialog method createDialogArea.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Composite tableComposite = new Composite(composite, SWT.None);
tableComposite.setLayout(new GridLayout());
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = WIDTH;
gridData.minimumWidth = WIDTH;
gridData.heightHint = HEIGHT;
gridData.minimumHeight = HEIGHT;
tableComposite.setLayoutData(gridData);
final TableViewerCreator tableViewerCreator = new TableViewerCreator(tableComposite);
tableViewerCreator.setBorderVisible(true);
tableViewerCreator.setCheckboxInFirstColumn(false);
tableViewerCreator.setColumnsResizableByDefault(true);
tableViewerCreator.setColumnsSortableByDefault(true);
tableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
Table table = tableViewerCreator.createTable();
table.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("MergeOrderDialog.Order"));
column.setModifiable(true);
column.setWidth(50);
//$NON-NLS-1$
column.setToolTipHeader(Messages.getString("MergeOrderDialog.CurrentOrderConnection"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {
public String get(Connection bean) {
return String.valueOf(connectionList.indexOf(bean) + 1);
}
public void set(Connection bean, String value) {
// bean.setName(value);
}
});
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("MergeOrderDialog.ConnectionName"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {
public String get(Connection bean) {
return getDisplayStr(bean);
}
public void set(Connection bean, String value) {
// bean.setName(value);
}
});
column.setModifiable(false);
column.setWidth(200);
tableViewerCreator.init(connectionList);
Composite buttonComposite = new Composite(composite, SWT.None);
buttonComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
Button moveUp = new Button(buttonComposite, SWT.PUSH);
//$NON-NLS-1$
moveUp.setToolTipText(Messages.getString("MergeOrderDialog.MoveUp"));
moveUp.setImage(ImageProvider.getImage(EImage.UP_ICON));
moveUp.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
Connection connection = (Connection) selection.getFirstElement();
int connId = connectionList.indexOf(connection);
if (connId > 0) {
Collections.swap(connectionList, connId - 1, connId);
tableViewerCreator.getTableViewer().refresh();
}
}
});
Button moveDown = new Button(buttonComposite, SWT.PUSH);
//$NON-NLS-1$
moveDown.setToolTipText(Messages.getString("MergeOrderDialog.MoveDown"));
moveDown.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
if (getMergeNode() != null && getMergeNode().isReadOnly()) {
moveUp.setEnabled(false);
moveDown.setEnabled(false);
}
final int nbConn = getConnectionQty();
moveDown.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
if (selection.size() > 0) {
Connection connection = (Connection) selection.getFirstElement();
int connId = connectionList.indexOf(connection);
if (connId < (nbConn - 1)) {
Collections.swap(connectionList, connId + 1, connId);
tableViewerCreator.getTableViewer().refresh();
}
}
}
});
return composite;
}
Aggregations