use of org.eclipse.swt.events.FocusListener in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method initListeners.
private void initListeners() {
assistText.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
if (e.stateMask == SWT.NONE) {
if (e.keyCode == SWT.ESC) {
disposeAssistText();
} else if (e.keyCode == SWT.CR) {
acceptProposal();
}
}
}
@Override
public void keyPressed(KeyEvent e) {
}
});
assistText.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (!(contentProposalAdapter.isProposalPopupOpen())) {
disposeAssistText();
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() {
@Override
public void proposalPopupOpened(ContentProposalAdapter adapter) {
}
@Override
public void proposalPopupClosed(ContentProposalAdapter adapter) {
if (assistText != null && !assistText.isFocusControl()) {
disposeAssistText();
}
}
});
contentProposalAdapter.addContentProposalListener(new IContentProposalListener() {
@Override
public void proposalAccepted(IContentProposal proposal) {
acceptProposal();
}
});
}
use of org.eclipse.swt.events.FocusListener in project tdi-studio-se by Talend.
the class DataMapTableView method createExpressionCellEditor.
protected TextCellEditor createExpressionCellEditor(final TableViewerCreator tableViewerCreator, TableViewerCreatorColumn column, final Zone[] zones, boolean isConstraintExpressionCellEditor) {
final TextCellEditorWithProposal cellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column);
final Text expressionTextEditor = (Text) cellEditor.getControl();
if (isConstraintExpressionCellEditor) {
// moved to it's caller to execute
// constraintExpressionTextEditor = expressionTextEditor;
} else {
columnExpressionTextEditor = expressionTextEditor;
}
cellEditor.addListener(new ICellEditorListener() {
Text text = (Text) cellEditor.getControl();
@Override
public void applyEditorValue() {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
mapperManager.getUiManager().parseNewExpression(text.getText(), (ITableEntry) modifiedObjectInfo.getCurrentModifiedBean(), true);
}
@Override
public void cancelEditor() {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
text.setText((String) modifiedObjectInfo.getOriginalPropertyBeanValue());
ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
String originalExpression = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
mapperManager.getUiManager().parseNewExpression(originalExpression, tableEntry, true);
}
@Override
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
if (expressionTextEditor.isFocusControl() || lastExpressionEditorTextWhichLostFocus == expressionTextEditor) {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
mapperManager.getUiManager().parseNewExpression(text.getText(), tableEntry, false);
resizeTextEditor(text, tableViewerCreator);
}
}
});
expressionTextEditor.addControlListener(new ControlListener() {
ExecutionLimiter executionLimiter = null;
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (executionLimiter == null) {
executionLimiter = new ExecutionLimiter(50, true) {
@Override
public void execute(boolean isFinalExecution, Object data) {
if (isFinalExecution && !expressionTextEditor.isDisposed()) {
expressionTextEditor.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (expressionTextEditor.isDisposed()) {
return;
}
resizeTextEditor(expressionTextEditor, tableViewerCreator);
}
});
}
}
};
}
executionLimiter.startIfExecutable();
}
});
expressionTextEditor.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
initExpressionProposals(cellEditor, zones, tableViewerCreator, currentModifiedEntry);
resizeTextEditor(expressionTextEditor, tableViewerCreator);
StyledTextHandler styledTextHandler = mapperManager.getUiManager().getTabFolderEditors().getStyledTextHandler();
styledTextHandler.setCurrentEntry(currentModifiedEntry);
//$NON-NLS-1$
styledTextHandler.setTextWithoutNotifyListeners(currentModifiedEntry.getExpression() == null ? "" : currentModifiedEntry.getExpression());
}
@Override
public void focusLost(FocusEvent e) {
expressionEditorTextSelectionBeforeFocusLost = expressionTextEditor.getSelection();
lastExpressionEditorTextWhichLostFocus = expressionTextEditor;
}
});
column.setCellEditor(cellEditor, new CellEditorValueAdapter() {
@Override
public Object getCellEditorTypedValue(CellEditor cellEditor, Object originalTypedValue) {
return super.getCellEditorTypedValue(cellEditor, originalTypedValue);
}
@Override
public String getColumnText(CellEditor cellEditor, Object bean, Object cellEditorTypedValue) {
//$NON-NLS-1$ //$NON-NLS-2$
return super.getColumnText(cellEditor, bean, cellEditorTypedValue).replaceAll("[\r\n\t]+", " ... ");
}
@Override
public Object getOriginalTypedValue(CellEditor cellEditor, Object cellEditorTypedValue) {
return super.getOriginalTypedValue(cellEditor, cellEditorTypedValue);
}
});
return cellEditor;
}
use of org.eclipse.swt.events.FocusListener in project tdi-studio-se by Talend.
the class RowGeneratorUI method addParentListeners.
/**
* qzhang Comment method "addParentListeners".
*
* @param uiManager
* @param uiProperties
*/
private void addParentListeners(final UIManager uiManager, final ExternalRowGeneratorUiProperties uiProperties) {
rowGenUIParent.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
if (uiManager.getRowGenResponse() == SWT.NONE) {
uiManager.closeRowGenerator(SWT.CANCEL, false);
}
}
});
rowGenUIParent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
updateBackground(false, true);
}
@Override
public void focusLost(FocusEvent e) {
}
});
// store size if not maximized
if (rowGenUIParent instanceof Shell) {
((Shell) rowGenUIParent).addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (!((Shell) e.getSource()).getMaximized()) {
ExternalRowGeneratorUiProperties.setBoundsRowGen(((Shell) e.getSource()).getBounds());
}
}
});
}
}
use of org.eclipse.swt.events.FocusListener 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.events.FocusListener in project tdi-studio-se by Talend.
the class OutputDataMapTableView method createMapSettingTable.
@Override
protected void createMapSettingTable() {
ExtendedTableModel<GlobalMapEntry> tableMapSettingEntriesModel = ((OutputTable) abstractDataMapTable).getTableMapSettingEntriesModel();
extendedTableViewerForMapSetting = new AbstractExtendedTableViewer<GlobalMapEntry>(tableMapSettingEntriesModel, centerComposite) {
@Override
protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
initMapSettingColumns(tableViewerCreator);
}
@Override
protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setBorderVisible(false);
}
};
if (tableMapSettingEntriesModel != null) {
tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, OUTPUT_REJECT, null));
tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, LOOK_UP_INNER_JOIN_REJECT, null));
if (getOutputTable().getIsJoinTableOf() == null) {
tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_TYPE, null));
if (getOutputTable().isRepository()) {
tableMapSettingEntriesModel.add(new GlobalMapEntry(abstractDataMapTable, SCHEMA_ID, null));
}
}
}
mapSettingViewerCreator = extendedTableViewerForMapSetting.getTableViewerCreator();
mapSettingTable = extendedTableViewerForMapSetting.getTable();
tableForMapSettingGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
mapSettingTable.setLayoutData(tableForMapSettingGridData);
mapSettingTable.setHeaderVisible(true);
mapSettingTable.setLinesVisible(true);
boolean mappingSettingVisible = false;
if (abstractDataMapTable instanceof AbstractInOutTable) {
mappingSettingVisible = ((AbstractInOutTable) abstractDataMapTable).isActivateCondensedTool();
}
tableForMapSettingGridData.exclude = !mappingSettingVisible;
mapSettingTable.setVisible(mappingSettingVisible);
mapSettingViewerCreator.getTableViewer().setSelection(null);
mapSettingTable.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
mapSettingViewerCreator.getTableViewer().setSelection(null);
}
public void focusGained(FocusEvent e) {
}
});
final TableViewer mapSettingTableViewer = mapSettingViewerCreator.getTableViewer();
mapSettingTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
selectThisDataMapTableView();
}
});
}
Aggregations