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);
}
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);
//
}
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());
}
}
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);
}
}
}
}
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);
}
Aggregations