use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class JSONToXPathLinker method updateLinksStyleAndControlsSelection.
@Override
@SuppressWarnings("unchecked")
public void updateLinksStyleAndControlsSelection(Control currentControl, Boolean flag) {
boolean selectedControlIsTable = false;
if (currentControl instanceof Table) {
selectedControlIsTable = true;
} else if (currentControl instanceof Tree) {
selectedControlIsTable = false;
} else {
throw new IllegalArgumentException("This type of currentControl is unsupported");
}
HashSet selectedItems = new HashSet();
Map itemsToSelect = new HashMap();
if (selectedControlIsTable) {
for (Table table : getTables()) {
if (table != currentControl) {
table.deselectAll();
if (isFieldsTable(table)) {
fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
}
TableItem[] selection = ((Table) currentControl).getSelection();
for (TableItem tableItem : selection) {
selectedItems.add(tableItem.getData());
}
} else {
TreeItem[] selection = getTree().getSelection();
for (TreeItem treeItem : selection) {
selectedItems.add(treeItem.getData());
}
}
List<LinkDescriptor<TreeItem, Object, Table, Object>> links = linksManager.getLinks();
for (LinkDescriptor<TreeItem, Object, Table, Object> link : links) {
IStyleLink styleLink = null;
IExtremityLink extremity = null;
IExtremityLink otherExtremity = null;
if (selectedControlIsTable) {
extremity = link.getExtremity2();
otherExtremity = link.getExtremity1();
} else {
extremity = link.getExtremity1();
otherExtremity = link.getExtremity2();
}
boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
if (extremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable() || otherExtremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable()) {
styleLink = getSelectedLoopStyleLink();
} else {
if (currentItemIsSelected) {
styleLink = getSelectedStyleLink();
if (selectedControlIsTable) {
itemsToSelect.put(otherExtremity.getGraphicalObject(), null);
} else {
Table currentTable = (Table) otherExtremity.getGraphicalObject();
List<TableItem> tableItemsToSelect = (List<TableItem>) itemsToSelect.get(currentTable);
if (tableItemsToSelect == null) {
tableItemsToSelect = new ArrayList<TableItem>();
itemsToSelect.put(currentTable, tableItemsToSelect);
}
TableItem tableItem = TableUtils.getTableItem(currentTable, otherExtremity.getDataItem());
tableItemsToSelect.add(tableItem);
}
} else {
styleLink = getUnselectedStyleLink();
}
}
if (styleLink == null) {
styleLink = getDefaultStyleLink();
}
link.setStyleLink(styleLink);
}
if (selectedControlIsTable) {
TreeItem[] treeItems = (TreeItem[]) itemsToSelect.keySet().toArray(new TreeItem[0]);
if (treeItems.length > 0) {
if (!treeItems[0].isDisposed()) {
(getTree()).setSelection(treeItems);
}
}
} else {
Set<Table> set = itemsToSelect.keySet();
if (set.size() > 0) {
for (Table table : set) {
ArrayList<TableItem> tableItemsToSelect = (ArrayList<TableItem>) itemsToSelect.get(table);
table.deselectAll();
TableItem[] tableItems = tableItemsToSelect.toArray(new TableItem[0]);
table.setSelection(tableItems);
}
} else {
loopTableEditorView.getTable().deselectAll();
fieldsTableEditorView.getTable().deselectAll();
}
fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
if (flag) {
getLinksManager().sortLinks(getDrawingLinksComparator());
getBackgroundRefresher().refreshBackground();
}
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class TableByRowController method createControl.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#
* createControl(org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
public Control createControl(final Composite parentComposite, final IElementParameter param, final int numInRow, final int nbInRow, int top, final Control lastControlPrm) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
final Composite container = parentComposite;
PropertiesTableEditorModel<Map<String, Object>> tableEditorModel = new PropertiesTableEditorModel<Map<String, Object>>();
if (param.getValue() == null || param.getValue().equals("")) {
param.setValue(new ArrayList<Map<String, Object>>());
}
init(elem, param);
tableEditorModel.setData(elem, param, getProcess(elem, part));
PropertiesTableByRowEditorView<Map<String, Object>> tableEditorView = new PropertiesTableByRowEditorView<Map<String, Object>>(parentComposite, SWT.NONE, tableEditorModel, true, false);
tableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
tableEditorView.setReadOnly(param.isReadOnly() || param.isRepositoryValueUsed());
tableEditorModel.setModifiedBeanListenable(tableEditorView.getTableViewerCreator());
tableEditorModel.addModifiedBeanListenerForAggregateComponent();
final Table table = tableEditorView.getTable();
table.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
// add listener to tableMetadata (listen the event of the toolbars)
tableEditorView.getExtendedTableModel().addAfterOperationListListener(new IListenableListListener() {
@Override
public void handleEvent(ListenableListEvent event) {
if (elem instanceof Node) {
Node node = (Node) elem;
node.checkAndRefreshNode();
}
}
});
final Composite mainComposite = tableEditorView.getMainComposite();
CLabel labelLabel2 = getWidgetFactory().createCLabel(container, param.getDisplayName());
FormData formData = new FormData();
if (lastControlPrm != null) {
formData.left = new FormAttachment(lastControlPrm, 0);
} else {
formData.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
formData.top = new FormAttachment(0, top);
labelLabel2.setLayoutData(formData);
if (numInRow != 1) {
labelLabel2.setAlignment(SWT.RIGHT);
}
// *********************
formData = new FormData();
int currentLabelWidth2 = STANDARD_LABEL_WIDTH;
GC gc2 = new GC(labelLabel2);
Point labelSize2 = gc2.stringExtent(param.getDisplayName());
gc2.dispose();
boolean needOffset = true;
if ((labelSize2.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth2) {
currentLabelWidth2 = labelSize2.x + ITabbedPropertyConstants.HSPACE;
needOffset = false;
}
int tableHorizontalOffset = -5;
if (numInRow == 1) {
if (lastControlPrm != null) {
if (needOffset) {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2);
}
} else {
if (needOffset) {
formData.left = new FormAttachment(0, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(0, currentLabelWidth2);
}
}
} else {
formData.left = new FormAttachment(labelLabel2, 0 + tableHorizontalOffset, SWT.RIGHT);
}
formData.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
formData.top = new FormAttachment(0, top);
int toolbarSize = 0;
if (!param.isBasedOnSchema()) {
Point size = tableEditorView.getExtendedToolbar().getToolbar().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y + 5;
}
int currentHeightEditor = table.getHeaderHeight() + 1 * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int minHeightEditor = table.getHeaderHeight() + getNumberLines(param) * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
ySize2 = Math.min(ySize2, 500);
formData.bottom = new FormAttachment(0, top + ySize2);
mainComposite.setLayoutData(formData);
hashCurControls.put(param.getName(), tableEditorView.getExtendedTableViewer().getTableViewerCreator());
hashCurControls.put(TOOLBAR_NAME, tableEditorView.getToolBar());
updateTableValues(param);
this.dynamicProperty.setCurRowSize(ySize2 + ITabbedPropertyConstants.VSPACE);
top += this.dynamicProperty.getCurRowSize();
return null;
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class TableByRowController method estimateRowSize.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
* (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
*/
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
PropertiesTableEditorModel<Map<String, Object>> tableEditorModel = new PropertiesTableEditorModel<Map<String, Object>>();
updateTableValues(param);
if (param.getValue() == null || param.getValue().equals("")) {
param.setValue(new ArrayList<Map<String, Object>>());
}
init(elem, param);
tableEditorModel.setData(elem, param, part.getProcess());
PropertiesTableByRowEditorView<Map<String, Object>> tableEditorView = new PropertiesTableByRowEditorView<Map<String, Object>>(subComposite, SWT.NONE, tableEditorModel, true, false);
tableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
tableEditorView.setReadOnly(param.isReadOnly());
final Table table = tableEditorView.getTable();
int toolbarSize = 0;
if (!param.isBasedOnSchema()) {
Point size = tableEditorView.getExtendedToolbar().getToolbar().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y + 5;
}
int currentHeightEditor = table.getHeaderHeight() + ((List) param.getValue()).size() * table.getItemHeight() + table.getItemHeight() + toolbarSize;
int minHeightEditor = table.getHeaderHeight() + getNumberLines(param) * table.getItemHeight() + table.getItemHeight() + toolbarSize;
tableEditorView.getMainComposite().dispose();
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
return ySize2 + ITabbedPropertyConstants.VSPACE;
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class HL7Tree2SchemaLinker method updateLinksStyleAndControlsSelection.
// private void getSelectedRelativeStyleLink() {
// StyleLink selectedStyleLink = new StyleLink();
// selectedStyleLink.setDrawableLink(new BezierHorizontalLink(selectedStyleLink));
// selectedStyleLink.setForegroundColor(selectedRelativeLinkColor);
// selectedStyleLink.setLineWidth(2);
// int xOffset = WindowSystem.isGTK() ? 2 : -2;
// int yOffset = WindowSystem.isGTK() ? -1 : 0;
// selectedStyleLink.setExtremity2(new ExtremityEastArrow(selectedStyleLink, -ExtremityEastArrow.WIDTH_ARROW +
// xOffset,
// yOffset));
// setSelectedStyleLink(selectedStyleLink);
// }
public void updateLinksStyleAndControlsSelection(Control currentControl, Boolean flag) {
boolean selectedControlIsTable = false;
if (currentControl instanceof Table) {
selectedControlIsTable = true;
} else if (currentControl instanceof Tree) {
selectedControlIsTable = false;
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("XmlToXPathLinker.illegalArgumentException"));
}
HashSet selectedItems = new HashSet();
Map itemsToSelect = new HashMap();
if (selectedControlIsTable) {
// for (Table table : getTables()) {
// if (table != currentControl) {
// table.deselectAll();
// if (isFieldsTable(table)) {
// fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
// }
// }
// }
TableItem[] selection = ((Table) currentControl).getSelection();
for (int i = 0; i < selection.length; i++) {
TableItem tableItem = selection[i];
selectedItems.add(tableItem.getData());
}
} else {
TreeItem[] selection = getTree().getSelection();
for (int i = 0; i < selection.length; i++) {
TreeItem treeItem = selection[i];
selectedItems.add(treeItem.getData());
}
}
List<LinkDescriptor<TreeItem, Object, Table, Object>> links = linksManager.getLinks();
for (LinkDescriptor<TreeItem, Object, Table, Object> link : links) {
IStyleLink styleLink = null;
IExtremityLink extremity = null;
IExtremityLink otherExtremity = null;
if (selectedControlIsTable) {
extremity = link.getExtremity2();
otherExtremity = link.getExtremity1();
} else {
extremity = link.getExtremity1();
otherExtremity = link.getExtremity2();
}
boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
// }
if (styleLink == null) {
styleLink = createStandardLink(new Color(getBgDrawableComposite().getDisplay(), 255, 102, 102));
}
link.setStyleLink(styleLink);
}
if (selectedControlIsTable) {
(getTree()).setSelection((TreeItem[]) itemsToSelect.keySet().toArray(new TreeItem[0]));
} else {
Set<Table> set = itemsToSelect.keySet();
if (set.size() > 0) {
for (Table table : set) {
ArrayList<TableItem> tableItemsToSelect = (ArrayList<TableItem>) itemsToSelect.get(table);
table.deselectAll();
TableItem[] tableItems = tableItemsToSelect.toArray(new TableItem[0]);
table.setSelection(tableItems);
}
} else {
// loopTableEditorView.getTable().deselectAll();
// fieldsTableEditorView.getTable().deselectAll();
}
// fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
getLinksManager().sortLinks(getDrawingLinksComparator());
getBackgroundRefresher().refreshBackground();
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class UIManager method getTableEntryPosition.
/**
* DOC amaumont Comment method "getTableEntryPosition".
*
* @param manager TODO
* @param tableEntry
* @param forceRecalculate TODO
* @return
*/
public Point getTableEntryPosition(ITableEntry tableEntry, boolean forceRecalculate) {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
int entriesSize = 0;
int minHeight = dataMapTableView.getTableViewerCreatorForColumns().getTable().getHeaderHeight() + dataMapTableView.getTableViewerCreatorForColumns().getTable().getItemHeight();
TableItem[] tableItems = new TableItem[0];
if (tableEntry instanceof InputColumnTableEntry || tableEntry instanceof OutputColumnTableEntry) {
tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
AbstractInOutTable abstractInOutTable = (AbstractInOutTable) dataMapTableView.getDataMapTable();
if (dataMapTableView.getZone() == Zone.OUTPUTS) {
OutputTable outputTable = (OutputTable) abstractInOutTable;
List<IColumnEntry> oldOuputEntries = outputTable.getDataMapTableEntries();
entriesSize = oldOuputEntries.size();
}
if (dataMapTableView.getZone() == Zone.INPUTS) {
InputTable inputTable = (InputTable) abstractInOutTable;
List<IColumnEntry> oldOuputEntries = inputTable.getDataMapTableEntries();
entriesSize = oldOuputEntries.size();
}
}
Rectangle tableViewBounds = dataMapTableView.getBounds();
Point pointFromTableViewOrigin = null;
Display display = dataMapTableView.getDisplay();
Point returnedPoint = new Point(0, 0);
TableEntryProperties tableEntryProperties = null;
int itemIndex = 0;
if (tableEntry instanceof IColumnEntry || tableEntry instanceof FilterTableEntry || tableEntry instanceof GlobalMapEntry) {
tableEntryProperties = mapperManager.getTableEntryProperties(tableEntry);
returnedPoint = tableEntryProperties.position;
if (forceRecalculate || returnedPoint == null) {
int y;
TableItem tableItem = mapperManager.retrieveTableItem(tableEntry);
boolean isOutputEntry = tableEntry instanceof OutputColumnTableEntry;
boolean isIntputEntry = tableEntry instanceof InputColumnTableEntry;
boolean checked = false;
for (int i = 0; i < tableItems.length; i++) {
if (tableItems[i].getData() == tableEntry) {
itemIndex = i;
break;
}
}
boolean allIsNull = false;
if (tableItem == null && (isIntputEntry || isOutputEntry)) {
if (tableItems.length > 0) {
tableItem = tableItems[0];
checked = true;
} else {
allIsNull = true;
}
}
if (!allIsNull) {
Table table = tableItem.getParent();
// FIX for issue 1225 ("1" parameter added)
Rectangle boundsTableItem = tableItem.getBounds(1);
y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
if (isOutputEntry || isIntputEntry) {
if (entriesSize != tableItems.length) {
y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
}
}
if (checked) {
y = boundsTableItem.y + dataMapTableView.getBorderWidth();
checked = false;
}
int x = 0;
if (y < 0) {
y = 0;
}
Point point = new Point(x, y);
pointFromTableViewOrigin = display.map(tableItem.getParent(), dataMapTableView, point);
} else {
Text columnFilterText = dataMapTableView.getColumnNameFilterText();
Point point = new Point(-dataMapTableView.getBorderWidth() - 19, minHeight);
pointFromTableViewOrigin = display.map(columnFilterText, dataMapTableView, point);
}
}
} else if (tableEntry instanceof ExpressionFilterEntry) {
StyledText expressionFilterText = dataMapTableView.getExpressionFilterText();
// dataMapTableView.getex
Point point = new Point(-dataMapTableView.getBorderWidth() - 19, 16);
pointFromTableViewOrigin = display.map(expressionFilterText, dataMapTableView, point);
} else {
//$NON-NLS-1$
throw new IllegalStateException("Case not found");
}
if (pointFromTableViewOrigin.y > tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION) {
pointFromTableViewOrigin.y = tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION;
}
returnedPoint = convertPointToReferenceOrigin(getReferenceComposite(), pointFromTableViewOrigin, dataMapTableView);
if (tableEntryProperties != null) {
tableEntryProperties.position = returnedPoint;
}
return returnedPoint;
}
Aggregations