Search in sources :

Example 1 with AsynchronousThreading

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();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) StyledTextHandler(org.talend.designer.xmlmap.ui.tabs.StyledTextHandler) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Example 2 with AsynchronousThreading

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();
}
Also used : TabFolderEditors(org.talend.designer.dbmap.ui.tabs.TabFolderEditors) FooterComposite(org.talend.designer.dbmap.ui.footer.FooterComposite) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) UIManager(org.talend.designer.dbmap.managers.UIManager) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) ExternalDbMapUiProperties(org.talend.designer.dbmap.external.data.ExternalDbMapUiProperties) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading) SashForm(org.eclipse.swt.custom.SashForm) InputTable(org.talend.designer.dbmap.model.table.InputTable) GridLayout(org.eclipse.swt.layout.GridLayout) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

Example 3 with AsynchronousThreading

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();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) StyledTextHandler(org.talend.designer.dbmap.ui.tabs.StyledTextHandler) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Example 4 with AsynchronousThreading

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();
    }
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) TableEntryLocation(org.talend.designer.mapper.model.tableentry.TableEntryLocation) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Aggregations

AsynchronousThreading (org.talend.commons.ui.runtime.thread.AsynchronousThreading)4 StyledText (org.eclipse.swt.custom.StyledText)2 Point (org.eclipse.swt.graphics.Point)2 UnnotifiableColorStyledText (org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText)2 SashForm (org.eclipse.swt.custom.SashForm)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Display (org.eclipse.swt.widgets.Display)1 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)1 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)1 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)1 DropTargetOperationListener (org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener)1 ExternalDbMapUiProperties (org.talend.designer.dbmap.external.data.ExternalDbMapUiProperties)1 UIManager (org.talend.designer.dbmap.managers.UIManager)1 InputTable (org.talend.designer.dbmap.model.table.InputTable)1 FooterComposite (org.talend.designer.dbmap.ui.footer.FooterComposite)1 StyledTextHandler (org.talend.designer.dbmap.ui.tabs.StyledTextHandler)1 TabFolderEditors (org.talend.designer.dbmap.ui.tabs.TabFolderEditors)1 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)1 InputDataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView)1