use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class DropTargetListenerForWebService method drop.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
*/
public void drop(DropTargetEvent event) {
if (getTransfer().isSupportedType(event.currentDataType)) {
// boolean canRemove = true;
// Parameter pa = TableEntriesTransfer.getInstance().getParameter();
Table draggableTable = (Table) draggableControl;
Point point = new Point(event.x, event.y);
int selevIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTable, point);
if (selevIndex < 0) {
return;
}
TableItem tabitem = TableEntriesTransfer.getInstance().getTableItem();
if (tabitem == null) {
return;
}
ExtendedTableModel tabelModel = draggableControlView.getExtendedTableModel();
if (tabelModel.getBeansList().size() == 0 || tabelModel.getBeansList().size() == selevIndex) {
// }
return;
} else if (tabelModel.getBeansList().size() > 0) {
if (tabelModel.getBeansList().size() < selevIndex) {
return;
}
Object objData = tabelModel.getBeansList().get(selevIndex);
if (objData instanceof InputMappingData) {
InputMappingData inData = (InputMappingData) objData;
IMetadataColumn inputColumn = null;
if (tabitem.getData() instanceof IMetadataColumn) {
inputColumn = (IMetadataColumn) tabitem.getData();
List<IMetadataColumn> columnList = inData.getMetadataColumnList();
if (inData.getInputColumnValue() == null || "".equals(inData.getInputColumnValue())) {
inData.setInputColumnValue(connector.initInRoWName() + "." + inputColumn.getLabel());
columnList.add(inputColumn);
} else {
inData.setInputColumnValue(inData.getInputColumnValue() + " " + connector.initInRoWName() + "." + inputColumn.getLabel());
columnList.add(inputColumn);
}
}
tabelModel.remove(selevIndex);
tabelModel.add(inData, selevIndex);
} else if (objData instanceof OutPutMappingData) {
OutPutMappingData outData = (OutPutMappingData) objData;
if (tabitem.getData() instanceof ParameterInfo) {
ParameterInfo para = (ParameterInfo) tabitem.getData();
if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
if (para.getParent() != null) {
String name = new ParameterInfoUtil().getParentName(para);
outData.setParameterName(name);
} else {
outData.setParameterName(para.getName());
}
} else {
outData.setParameterName(outData.getParameterName() + " " + para.getName());
}
outData.getParameterList().add(para);
// outData.setParameter(para);
} else if (tabitem.getData() instanceof OutPutMappingData) {
if (((OutPutMappingData) tabitem.getData()).getParameter() instanceof ParameterInfo) {
ParameterInfo para = ((OutPutMappingData) tabitem.getData()).getParameter();
if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
if (para.getParent() != null) {
String name = "";
if (((OutPutMappingData) tabitem.getData()).getParameterName() != null) {
name = ((OutPutMappingData) tabitem.getData()).getParameterName();
} else {
name = new ParameterInfoUtil().getParentName(para);
}
outData.setParameterName(name);
} else {
outData.setParameterName(para.getName());
}
} else {
outData.setParameterName(outData.getParameterName() + " " + para.getName());
}
outData.getParameterList().add(para);
// outData.setParameter(para);
}
}
tabelModel.remove(selevIndex);
tabelModel.add(outData, selevIndex);
}
}
TableItem[] items = draggableTable.getSelection();
if (items.length <= 0) {
return;
}
TableItem itemTarget = items[0];
itemTarget.setChecked(true);
createLinks(itemTarget, tabitem, tabelModel.getName());
}
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class WebServiceTableLiner method addLinks.
public void addLinks(TableItem itemSource, Object data1, Table tableTarget, Object data2, String mark) {
LinkDescriptor<TableItem, Object, Table, Object> link = new LinkDescriptor<TableItem, Object, Table, Object>(new TableExtremityDescriptor(itemSource, data1), new ExtremityLink<Table, Object>(tableTarget, data2));
link.setStyleLink(createStandardLink(new Color(getBgDrawableComposite().getDisplay(), 255, 102, 102)));
getLinksManager().addLink(link);
if (mark.equals("INPUTMAPPING")) {
sourceInList.add(((IMetadataColumn) itemSource.getData()).getLabel());
} else if (mark.equals("OUTPUTMAPPING")) {
if (((OutPutMappingData) itemSource.getData()).getParameterName() != null) {
String sourseName = ((OutPutMappingData) itemSource.getData()).getParameterName();
// int m = sourseName.lastIndexOf(".");
// sourseName = sourseName.substring(m + 1);
sourceOutList.add(sourseName);
} else {
sourceOutList.add(((OutPutMappingData) itemSource.getData()).getParameter().getName());
}
}
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
default:
return null;
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class LibraryField method createTable.
@Override
protected Table createTable(Composite parent) {
Table contextTable = new Table(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
contextTable.setLinesVisible(false);
contextTable.setHeaderVisible(true);
TableColumn moduleNameColumn = new TableColumn(contextTable, SWT.LEFT);
//$NON-NLS-1$
moduleNameColumn.setText(Messages.getString("LibraryField.moduleColumn"));
moduleNameColumn.setWidth(120);
TableColumn colName = new TableColumn(contextTable, SWT.NONE);
//$NON-NLS-1$
colName.setText(Messages.getString("LibraryField.requiredColumn"));
colName.setWidth(70);
TableColumn descriptionColumn = new TableColumn(contextTable, SWT.NONE);
//$NON-NLS-1$
descriptionColumn.setText(Messages.getString("LibraryField.descriptionColumn"));
descriptionColumn.setWidth(200);
return contextTable;
}
use of org.eclipse.swt.widgets.Table in project tdi-studio-se by Talend.
the class Schema2XMLLinker method updateLinksStyleAndControlsSelection.
@SuppressWarnings("unchecked")
public void updateLinksStyleAndControlsSelection(Control currentControl) {
// super.updateLinksStyleAndControlsSelection(currentControl);
boolean isTarget = false;
if (getSource() != currentControl) {
isTarget = true;
} else {
isTarget = false;
}
HashSet selectedItems = new HashSet();
Map itemsToSelect = new HashMap();
if (isTarget) {
getTarget().deselectAll();
TreeItem[] selection = getTarget().getSelection();
for (TreeItem tableItem : selection) {
selectedItems.add(tableItem.getData());
}
} else {
TableItem[] selection = getSource().getSelection();
for (TableItem treeItem : selection) {
selectedItems.add(treeItem.getData());
}
}
List<LinkDescriptor<Item, Object, Tree, Object>> links = linksManager.getLinks();
for (LinkDescriptor<Item, Object, Tree, Object> link : links) {
IStyleLink styleLink = null;
IExtremityLink extremity = null;
IExtremityLink otherExtremity = null;
if (isTarget) {
extremity = link.getExtremity2();
otherExtremity = link.getExtremity1();
} else {
extremity = link.getExtremity1();
otherExtremity = link.getExtremity2();
}
boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
if (extremity.getGraphicalObject() == xmlViewer.getTree() || otherExtremity.getGraphicalObject() == xmlViewer.getTree()) {
styleLink = getSelectedLoopStyleLink();
} else {
if (currentItemIsSelected) {
styleLink = getSelectedStyleLink();
if (isTarget) {
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 (isTarget) {
(getSource()).setSelection((TableItem[]) itemsToSelect.keySet().toArray(new TableItem[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 {
xmlViewer.getTree().deselectAll();
}
}
getLinksManager().sortLinks(getDrawingLinksComparator());
}
Aggregations