Search in sources :

Example 36 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class MapperManager method addOutput.

/**
     * DOC amaumont Comment method "addOutput".
     */
public void addOutput() {
    String tableName = uiManager.openNewOutputCreationDialog();
    if (tableName == null) {
        return;
    }
    IProcess process = mapperComponent.getProcess();
    //$NON-NLS-1$
    String uniqueName = process.generateUniqueConnectionName("table");
    process.addUniqueConnectionName(uniqueName);
    MetadataTable metadataTable = new MetadataTable();
    metadataTable.setTableName(uniqueName);
    // metadataTable.setId(uniqueName);
    metadataTable.setLabel(tableName);
    List<DataMapTableView> outputsTablesView = getUiManager().getOutputsTablesView();
    int sizeOutputsView = outputsTablesView.size();
    Control lastChild = null;
    if (sizeOutputsView - 1 >= 0) {
        lastChild = outputsTablesView.get(sizeOutputsView - 1);
    }
    IDataMapTable abstractDataMapTable = new OutputTable(this, metadataTable, uniqueName, tableName);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    tablesZoneViewOutputs.layout();
    uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
Also used : Control(org.eclipse.swt.widgets.Control) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) 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) TablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 37 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class UIManager method changeSchemasDetailView.

/**
     * 
     * cLi Comment method "refreshSchemasDetailView".
     * 
     * refresh schema details view by different provider.
     */
public void changeSchemasDetailView(final TreeViewer schemaDetailsViewer, boolean model) {
    if (schemaDetailsViewer == null || schemaDetailsViewer.getTree().isDisposed()) {
        return;
    }
    final Tree tree = schemaDetailsViewer.getTree();
    // removed all columns
    final TreeColumn[] columns = tree.getColumns();
    for (TreeColumn col : columns) {
        col.dispose();
    }
    if (columnTreeEditor != null) {
        columnTreeEditor.dispose();
        final Control editor = columnTreeEditor.getEditor();
        if (editor != null && !editor.isDisposed()) {
            editor.setVisible(false);
            editor.dispose();
        }
        columnTreeEditor = null;
    }
    if (columnMouseListener != null) {
        tree.removeMouseListener(columnMouseListener);
        columnMouseListener = null;
    }
    SchemaDetailsProvider provider = null;
    if (model) {
        // is properties model
        provider = new SchemaDetailsPropertiesProvider(this);
        List<String> columnProperties = new ArrayList<String>();
        List<CellEditor> cellEidors = new ArrayList<CellEditor>();
        for (EPropertyName pName : EPropertyName.values()) {
            columnProperties.add(pName.name());
            TreeColumn pColumn = new TreeColumn(tree, SWT.NONE);
            pColumn.setWidth(100);
            pColumn.setText(pName.getName());
            final CellEditor cellEditor;
            switch(pName) {
                case NAME:
                case LENGTH:
                case TAGLEVEL:
                // case CARD:
                case PATTERN:
                    cellEditor = new SchemaDetailsTextCellEditor(schemaDetailsViewer, pName);
                    break;
                case KEY:
                    pColumn.setToolTipText("Only one column can be set as key.");
                    cellEditor = new SchemaDetailsCheckBoxCellEditor(tree);
                    break;
                // break;
                case TYPE:
                    cellEditor = new ComboBoxCellEditor(tree, MultiSchemasUtil.getTalendTypeLabel(), SWT.READ_ONLY);
                    break;
                default:
                    cellEditor = null;
            }
            if (cellEditor != null) {
                cellEidors.add(cellEditor);
            }
        }
        schemaDetailsViewer.setColumnProperties(columnProperties.toArray(new String[0]));
        schemaDetailsViewer.setCellEditors(cellEidors.toArray(new CellEditor[0]));
        schemaDetailsViewer.setCellModifier(new SchemaDetailsPropertiesCellModifier(schemaDetailsViewer, this));
        // set sorter
        TreeColumn sorterColumn = tree.getColumn(0);
        sorterColumn.addListener(SWT.Selection, new SchemaDetailsViewerSorterListener(schemaDetailsViewer));
        tree.setSortColumn(sorterColumn);
        tree.setSortDirection(SWT.UP);
        schemaDetailsViewer.setSorter(new SchemaDetailsViewerSorter(schemaDetailsViewer, sorterColumn, tree.getSortDirection() == SWT.UP));
    } else {
        // is column model
        provider = new SchemaDetailsColumnsProvider(this);
        // first columm is fixed.
        TreeColumn propertyColumn = new TreeColumn(tree, SWT.NONE);
        propertyColumn.setWidth(80);
        propertyColumn.setResizable(false);
        //
        columnTreeEditor = new TreeEditor(tree);
        columnTreeEditor.horizontalAlignment = SWT.LEFT;
        columnTreeEditor.grabHorizontal = true;
        columnMouseListener = new SchemaDetailsColumnMouseAdapter(schemaDetailsViewer, columnTreeEditor, this);
        tree.addMouseListener(columnMouseListener);
    }
    schemaDetailsViewer.setContentProvider(provider);
    schemaDetailsViewer.setLabelProvider(provider);
//
}
Also used : SchemaDetailsTextCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsTextCellEditor) SchemaDetailsPropertiesCellModifier(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesCellModifier) SchemaDetailsColumnsProvider(org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnsProvider) SchemaDetailsPropertiesProvider(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesProvider) TreeEditor(org.eclipse.swt.custom.TreeEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SchemaDetailsTextCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsTextCellEditor) SchemaDetailsCheckBoxCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsCheckBoxCellEditor) ArrayList(java.util.ArrayList) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SchemaDetailsViewerSorterListener(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsViewerSorterListener) SchemaDetailsColumnMouseAdapter(org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnMouseAdapter) SchemaDetailsCheckBoxCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsCheckBoxCellEditor) Control(org.eclipse.swt.widgets.Control) SchemaDetailsViewerSorter(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsViewerSorter) EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) SchemaDetailsProvider(org.talend.designer.filemultischemas.ui.provider.SchemaDetailsProvider)

Example 38 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class SchemaDetailsColumnMouseAdapter method mouseDown.

@Override
public void mouseDown(MouseEvent e) {
    currentPoint = new Point(e.x, e.y);
    // Clean up any previous editor control
    Control oldEditor = getEditor();
    if (oldEditor != null) {
        oldEditor.dispose();
    }
    if (getViewerCell() == null) {
        return;
    }
    // Identify the selected row
    TreeItem item = (TreeItem) getViewerCell().getViewerRow().getItem();
    if (item == null) {
        return;
    }
    if (getColumnIndex() < 1) {
        // ingore first
        return;
    }
    final Object data = item.getData();
    if (!(data instanceof ColumnLineData)) {
        return;
    }
    ColumnLineData lineData = (ColumnLineData) data;
    List<MultiMetadataColumn> metadataColumnsInModel = lineData.getKeyData().getMetadataColumnsInModel();
    final MultiMetadataColumn multiMetadataColumn = metadataColumnsInModel.get(getColumnIndex() - 1);
    Control newEditor = null;
    final EPropertyName property = lineData.getProperty();
    if (UIManager.isFirstForColumnModel(property)) {
        newEditor = createTextControl(item, property, multiMetadataColumn);
    } else {
        switch(property) {
            case NAME:
            case TAGLEVEL:
                break;
            case TYPE:
                newEditor = createComboControl(item, multiMetadataColumn);
                break;
            case LENGTH:
            // case CARD:
            case PATTERN:
                newEditor = createTextControl(item, property, multiMetadataColumn);
                break;
            case KEY:
                /*
                 * ingore record type(first column);
                 * 
                 * if existed key column, should not edit other key.
                 */
                if (getColumnIndex() == uiManager.getSelectedColumnIndex() + 1 || UIManager.existedKeyColumn(metadataColumnsInModel, multiMetadataColumn)) {
                    break;
                }
                newEditor = createCheckBoxControl(item, property, multiMetadataColumn);
                break;
        }
    }
    if (newEditor != null) {
        newEditor.addFocusListener(new FocusAdapter() {

            public void focusLost(FocusEvent e) {
                if (getEditor() != null && !getEditor().isDisposed()) {
                    getEditor().dispose();
                }
            }
        });
        newEditor.setFocus();
        getTreeEditor().setEditor(newEditor, item, getColumnIndex());
    }
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Control(org.eclipse.swt.widgets.Control) EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) TreeItem(org.eclipse.swt.widgets.TreeItem) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 39 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class RowGenMain method addAllControlForKeyListener.

/**
     * qzhang Comment method "addAllControlForKeyListener".
     * 
     * @param parent
     * @param keyAdapter
     * @return
     */
private void addAllControlForKeyListener(Control parent) {
    KeyAdapter keyAdapter = new KeyAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
             */
        @Override
        public void keyReleased(KeyEvent e) {
            if (e.keyCode == SWT.F5) {
                MetadataTableEditorViewExt viewExt = generatorUI.getDataTableView();
                viewExt.refreshPreviewColumn();
            }
        }
    };
    parent.addKeyListener(keyAdapter);
    if (parent instanceof Composite) {
        Control[] children = ((Composite) parent).getChildren();
        for (Control control : children) {
            if (control != null && !control.isDisposed()) {
                addAllControlForKeyListener(control);
            }
        }
    }
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MetadataTableEditorViewExt(org.talend.designer.rowgenerator.ui.editor.MetadataTableEditorViewExt)

Example 40 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class CpuDumpEditor method refreshCallersCalleesPage.

/**
     * Refreshes the callers/callees page.
     */
private void refreshCallersCalleesPage() {
    Label label = null;
    SashForm sashForm = null;
    for (Control control : callersCalleesPageBook.getChildren()) {
        if (control instanceof Label) {
            label = (Label) control;
        } else if (control instanceof SashForm) {
            sashForm = (SashForm) control;
        }
    }
    if (label == null || sashForm == null) {
        //$NON-NLS-1$
        throw new IllegalStateException("label and sashform cannot be null");
    }
    Control control = (cpuModel.getCallersCalleesTarget() == null) ? label : sashForm;
    callersCalleesPageBook.showPage(control);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Control(org.eclipse.swt.widgets.Control) Label(org.eclipse.swt.widgets.Label)

Aggregations

Control (org.eclipse.swt.widgets.Control)475 Point (org.eclipse.swt.graphics.Point)149 Composite (org.eclipse.swt.widgets.Composite)141 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)93 Label (org.eclipse.swt.widgets.Label)73 GridLayout (org.eclipse.swt.layout.GridLayout)71 Text (org.eclipse.swt.widgets.Text)70 FormData (org.eclipse.swt.layout.FormData)62 FormAttachment (org.eclipse.swt.layout.FormAttachment)61 Node (org.talend.designer.core.ui.editor.nodes.Node)46 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)45 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 StyledText (org.eclipse.swt.custom.StyledText)42 GC (org.eclipse.swt.graphics.GC)41 CLabel (org.eclipse.swt.custom.CLabel)38 ArrayList (java.util.ArrayList)36 Shell (org.eclipse.swt.widgets.Shell)35 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)33 CCombo (org.eclipse.swt.custom.CCombo)32