use of org.talend.commons.ui.runtime.thread.AsynchronousThreading in project tdi-studio-se by Talend.
the class ExpressionCellEditor method highlightLineAndSetSelectionOfStyledTextFromTextControl.
protected void highlightLineAndSetSelectionOfStyledTextFromTextControl(final Control textWidget) {
final StyledTextHandler styledTextHandler = mapperManager.getMapperUI().getTabFolderEditors().getStyledTextHandler();
Runnable runnable = new Runnable() {
public void run() {
StyledText styledText = styledTextHandler.getStyledText();
if (styledText.isDisposed() || textWidget.isDisposed()) {
return;
}
String text = ControlUtils.getText(textWidget);
Point selection = ControlUtils.getSelection(textWidget);
String lineDelimiter = ControlUtils.getLineDelimiter(textWidget);
if (selection.x - 1 > 0) {
while (lineDelimiter.equals(text.charAt(selection.x - 1))) {
selection.x++;
}
}
if (selection.y - 1 > 0) {
while (lineDelimiter.equals(text.charAt(selection.y - 1))) {
selection.y++;
}
}
int length = styledText.getText().length();
if (selection.x < 0) {
selection.x = 0;
}
if (selection.x > length) {
selection.x = length;
}
if (selection.y < 0) {
selection.y = 0;
}
if (selection.y > length) {
selection.y = length;
}
styledText.setSelection(selection);
styledTextHandler.highlightLineOfCursorPosition(selection);
}
};
new AsynchronousThreading(50, true, parent.getDisplay(), runnable).start();
}
use of org.talend.commons.ui.runtime.thread.AsynchronousThreading in project tdi-studio-se by Talend.
the class MapperUI method init.
public void init(MapperModel mapperModel) {
// long time1 = System.currentTimeMillis();
// CommandStack commandStack = new CommandStackForComposite(this.mapperUIParent);
// mapperManager.setCommandStack(commandStack);
final UIManager uiManager = mapperManager.getUiManager();
final ExternalDbMapUiProperties uiProperties = uiManager.getUiProperties();
addParentListeners(uiManager, uiProperties);
final Display display = mapperUIParent.getDisplay();
bgColorLinksZone = ColorProviderMapper.getColor(ColorInfo.COLOR_BACKGROUND_LINKS_ZONE);
GridLayout parentLayout = new GridLayout(1, true);
mapperUIParent.setLayout(parentLayout);
addKeyListener(uiManager, display);
addBackgroundRefreshLimiters(display);
this.dropTargetOperationListener = new DropTargetOperationListener(mapperManager);
dropTargetOperationListener.addControl(this.mapperUIParent.getShell());
mainSashForm = new SashForm(mapperUIParent, SWT.SMOOTH | SWT.VERTICAL);
GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
mainSashForm.setLayoutData(mainSashFormGridData);
datasFlowViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
datasFlowViewSashForm.setBackgroundMode(SWT.INHERIT_FORCE);
initBackgroundComponents();
if (WindowSystem.isGTK()) {
datasFlowViewSashForm.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
}
// dropTargetOperationListener.addControl(datasFlowViewSashForm);
// datasFlowViewSashForm.addControlListener(new ControlListener() {
//
// public void controlMoved(ControlEvent e) {
// }
//
// public void controlResized(ControlEvent e) {
// createBgImages();
// updateBackground(true, false);
// }
//
// });
/* Create the tabs */
String dbmsId = null;
if (mapperModel.getInputDataMapTables() != null && !mapperModel.getInputDataMapTables().isEmpty()) {
InputTable input = mapperModel.getInputDataMapTables().get(0);
if (input.getMetadataTable() != null) {
dbmsId = input.getMetadataTable().getDbms();
}
}
tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager, dbmsId);
createInputZoneWithTables(mapperModel, uiManager, display);
createVarsZoneWithTables(mapperModel, display);
createOutputZoneWithTables(mapperModel, uiManager, display);
mapperManager.initInternalData();
uiManager.parseAllExpressionsForAllTables();
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
this.draggingInfosPopup = DraggingInfosPopup.getNewShell(this.mapperUIParent.getShell());
configureZoneScrollBars(display);
int[] weightsDatasFlowViewSashForm = uiProperties.getWeightsDatasFlowViewSashForm();
datasFlowViewSashForm.setWeights(weightsDatasFlowViewSashForm.length != 0 ? weightsDatasFlowViewSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_DATAS_FLOW_SASH_FORM);
int[] weightsMainSashForm = uiProperties.getWeightsMainSashForm();
mainSashForm.setWeights(weightsMainSashForm.length != 0 ? weightsMainSashForm : ExternalDbMapUiProperties.DEFAULT_WEIGHTS_MAIN_SASH_FORM);
new FooterComposite(this.mapperUIParent, SWT.NONE, mapperManager);
if (WindowSystem.isGTK()) {
// resize especially for GTK
new AsynchronousThreading(1000, false, display, new Runnable() {
public void run() {
resizeNotMinimizedTablesAtExpandedSize(display);
mapperUIParent.getShell().layout();
}
}).start();
}
if (WindowSystem.isWIN32()) {
List<DataMapTableView> inputsTablesView = uiManager.getInputsTablesView();
for (DataMapTableView view : inputsTablesView) {
((InputDataMapTableView) view).refreshLabelForJoinDropDown();
}
}
selectFirstInOutTablesView();
mapperManager.getUiManager().refreshSqlExpression();
}
use of org.talend.commons.ui.runtime.thread.AsynchronousThreading in project tdi-studio-se by Talend.
the class DataMapTableView method highlightLineAndSetSelectionOfStyledText.
private void highlightLineAndSetSelectionOfStyledText(final Text expressionTextEditor) {
final StyledTextHandler styledTextHandler = mapperManager.getUiManager().getTabFolderEditors().getStyledTextHandler();
Runnable runnable = new Runnable() {
@Override
public void run() {
StyledText styledText = styledTextHandler.getStyledText();
if (styledText.isDisposed()) {
return;
}
String text = expressionTextEditor.getText();
Point selection = expressionTextEditor.getSelection();
if (selection.x - 1 > 0) {
while (expressionTextEditor.getLineDelimiter().equals(text.charAt(selection.x - 1))) {
selection.x++;
}
}
if (selection.y - 1 > 0) {
while (expressionTextEditor.getLineDelimiter().equals(text.charAt(selection.y - 1))) {
selection.y++;
}
}
int length = styledText.getText().length();
if (selection.x < 0) {
selection.x = 0;
}
if (selection.x > length) {
selection.x = length;
}
if (selection.y < 0) {
selection.y = 0;
}
if (selection.y > length) {
selection.y = length;
}
styledText.setSelection(selection);
styledTextHandler.highlightLineOfCursorPosition(selection);
}
};
new AsynchronousThreading(50, true, DataMapTableView.this.getDisplay(), runnable).start();
}
use of org.talend.commons.ui.runtime.thread.AsynchronousThreading in project tdi-studio-se by Talend.
the class UIManager method processColumnNameChanged.
/**
* DOC amaumont Comment method "processNewProcessColumnName".
*
* @param previousColumnName TODO
* @param dataMapTableView
* @param text
* @param entry
*/
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry) {
mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
boolean atLeastOneLinkHasBeenRemoved = false;
for (DataMapTableView view : tableViews) {
IDataMapTable dataMapTable = view.getDataMapTable();
List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
for (IColumnEntry entry : metadataTableEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
// for the input/output table expression filter
if (dataMapTable instanceof AbstractInOutTable) {
ExpressionFilterEntry expressionFilterEntry = ((AbstractInOutTable) dataMapTable).getExpressionFilter();
if (expressionFilterEntry != null && expressionFilterEntry.getExpression() != null) {
if (parseExpression(expressionFilterEntry.getExpression(), expressionFilterEntry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
}
}
mapperManager.getUiManager().refreshBackground(false, false);
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
if (atLeastOneLinkHasBeenRemoved) {
new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
public void run() {
TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(), //$NON-NLS-1$
Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
Messages.getString("UIManager.propagateMessage"));
if (propagate) {
TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
}
}
}).start();
}
}
Aggregations