use of org.eclipse.swt.widgets.Item in project translationstudio8 by heartsome.
the class CustomMatchContributionItem method fill.
@Override
public void fill(Menu menu, int index) {
LinkedHashMap<String, String> map = XLFHandler.getCustomMatchFilterMap();
if (map == null || map.size() == 0) {
for (Item item : menu.getItems()) {
if (!item.isDisposed()) {
item.dispose();
}
}
} else {
for (Entry<String, String> entry : map.entrySet()) {
final String xpath = entry.getValue();
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(entry.getKey());
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
if (xliffEditor == null) {
return;
}
xliffEditor.getXLFHandler().deleteAltTrans(xpath);
ArrayList<Integer> rowList = new ArrayList<Integer>();
int[] rows = xliffEditor.getSelectedRows();
for (int i : rows) {
rowList.add(i);
}
StructuredSelection selection = new StructuredSelection(rowList);
xliffEditor.getSite().getSelectionProvider().setSelection(selection);
}
});
}
}
}
use of org.eclipse.swt.widgets.Item 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());
}
use of org.eclipse.swt.widgets.Item in project tdi-studio-se by Talend.
the class JSONFileSchema2TreeLinker method addLink.
private LinkDescriptor<Item, Object, Tree, Object> addLink(Item tableItem, Object dataItem1, Tree tree, Object dataItem2, boolean lastOne) {
LinkDescriptor<Item, Object, Tree, Object> link = new LinkDescriptor<Item, Object, Tree, Object>(new ItemExtremityDescriptor(tableItem, dataItem1), new ExtremityLink<Tree, Object>(tree, dataItem2));
link.setStyleLink(getUnselectedStyleLink());
getLinksManager().addLink(link);
updateLinksStyleAndControlsSelection(tree, lastOne);
return link;
}
use of org.eclipse.swt.widgets.Item in project tdi-studio-se by Talend.
the class AddArrayIndexForParentsDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite createDialogArea = (Composite) super.createDialogArea(parent);
FillLayout layout = new FillLayout();
// layout.horizontalSpacing = 1;
// layout.numColumns = 1;
GridData data = new GridData(GridData.FILL_BOTH);
createDialogArea.setLayout(layout);
createDialogArea.setLayoutData(data);
table = new TableViewer(createDialogArea, SWT.FULL_SELECTION | SWT.BORDER);
new TableColumn(table.getTable(), SWT.LEFT).setText(COLUMN_NAME[0]);
table.getTable().getColumn(0).pack();
new TableColumn(table.getTable(), SWT.LEFT).setText(COLUMN_NAME[1]);
table.getTable().getColumn(1).pack();
table.getTable().setHeaderVisible(true);
table.getTable().setLinesVisible(true);
table.setContentProvider(new IndexContentProvider());
table.setLabelProvider(new IndexLabelProvider());
table.setInput(arrayIndexList);
table.setColumnProperties(COLUMN_NAME);
CellEditor[] editors = new CellEditor[2];
editors[0] = null;
editors[1] = new TextCellEditor(table.getTable());
table.setCellEditors(editors);
table.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(COLUMN_NAME[0]))
return false;
return true;
}
public Object getValue(Object element, String property) {
ArrayIndexList index = (ArrayIndexList) element;
if (property.equals(COLUMN_NAME[1])) {
if (index.getIndexNum() != null) {
return index.getIndexNum();
} else {
return "";
}
}
return null;
}
public void modify(Object element, String property, Object value) {
if (element instanceof Item)
element = ((Item) element).getData();
ArrayIndexList index = (ArrayIndexList) element;
if (property.equals(COLUMN_NAME[1]))
index.setIndexNum((String) value);
table.refresh();
}
});
return createDialogArea;
}
use of org.eclipse.swt.widgets.Item in project tdi-studio-se by Talend.
the class SchemaXMLLinker method addLink.
/**
* amaumont Comment method "addLink".
*
* @param tableItem
* @param dataItem1
* @param tree
* @param dataItem2
*/
private LinkDescriptor<Item, Object, Tree, Object> addLink(Item tableItem, Object dataItem1, Tree tree, Object dataItem2, boolean lastOne) {
LinkDescriptor<Item, Object, Tree, Object> link = new LinkDescriptor<Item, Object, Tree, Object>(new ItemExtremityDescriptor(tableItem, dataItem1), new ExtremityLink<Tree, Object>(tree, dataItem2));
link.setStyleLink(getUnselectedStyleLink());
getLinksManager().addLink(link);
updateLinksStyleAndControlsSelection(tree, lastOne);
return link;
}
Aggregations