use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class Type3Section method removeDragItems.
/*
* (non-Javadoc)
*
* @see org.talend.designer.scd.ui.IDragDropDelegate#removeDragItems()
*/
public void removeDragItems(String data) {
TableItem[] items = table.getItems();
//$NON-NLS-1$
String[] toRemove = data.split("\\|");
for (int i = 1; i < toRemove.length; i++) {
// skip items[0], which is the number of selected elements
TableItem itemToRemove = null;
for (TableItem item : items) {
if (toRemove[i].equals(item.getText())) {
itemToRemove = item;
break;
}
}
if (itemToRemove != null) {
tableModel.remove(itemToRemove.getData());
if (scdManager.getTypeTable().contains(toRemove[i])) {
scdManager.getTypeTable().remove(toRemove[i]);
}
editorManager.removeEditors(itemToRemove);
}
}
table.remove(table.getSelectionIndices());
tableViewer.refresh();
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method addItemElements.
@Override
protected void addItemElements(List<ItemVersionObject> elements) {
if (elements == null || elements.isEmpty()) {
return;
}
itemTable.setRedraw(false);
for (final ItemVersionObject object : elements) {
final TableItem tableItem = new TableItem(itemTable, SWT.CENTER);
tableItem.setData(object);
Item item = object.getItem();
IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
Image itemsImage = null;
if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
} else {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
}
tableItem.setImage(itemsImage);
tableItem.setText(item.getProperty().getLabel());
// old version
tableItem.setText(1, MavenVersionUtils.getItemMavenVersion(item.getProperty()));
TableEditor versionEditor = null;
if (fixedVersionButton.getSelection()) {
tableItem.setText(2, appliedFixedVersion);
} else if (useJobVersionButton.getSelection()) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(item.getProperty().getVersion());
tableItem.setText(2, jobDefaultVersion);
object.setNewVersion(jobDefaultVersion);
} else {
// new version
versionEditor = new TableEditor(itemTable);
Composite versionComposite = new Composite(itemTable, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
layout.marginRight = 1;
versionComposite.setLayout(layout);
final Text text = new Text(versionComposite, SWT.CENTER | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
text.setLayoutData(data);
String newVersion = object.getNewVersion();
if (newVersion == null || "".equals(newVersion.trim())) {
//$NON-NLS-1$
newVersion = appliedFixedVersion;
object.setNewVersion(newVersion);
}
text.setText(newVersion);
checkVersionPattern(text, newVersion);
text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String version = text.getText();
checkVersionPattern(text, version);
object.setNewVersion(version);
checkValid();
}
});
versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
versionEditor.setEditor(versionComposite, tableItem, 2);
}
TableEditor delEditor = new TableEditor(itemTable);
Label delLabel = new Label(itemTable, SWT.CENTER);
delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
//$NON-NLS-1$
delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
delLabel.pack();
delLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
checkedObjects.remove(object);
removeTableItem(tableItem);
refreshCheckedTreeView();
checkButtonsState();
checkButtonsState(false);
}
});
delEditor.minimumWidth = 25;
delEditor.horizontalAlignment = SWT.CENTER;
delEditor.setEditor(delLabel, tableItem, 3);
if (fixedVersionButton.getSelection() || useJobVersionButton.getSelection()) {
tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
} else if (versionEditor != null) {
tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
}
itemTable.setRedraw(true);
}
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method refreshCheckedTreeView.
protected void refreshCheckedTreeView() {
List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
for (TableItem item : itemTable.getItems()) {
Object data = item.getData();
if (data instanceof ItemVersionObject) {
nodes.add(((ItemVersionObject) data).getRepositoryNode());
}
}
treeViewer.setCheckedElements(nodes.toArray());
// treeViewer.refresh();
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method removeItemElements.
protected void removeItemElements(List<ItemVersionObject> objects) {
itemTable.setRedraw(false);
TableItem[] items = itemTable.getItems();
for (TableItem item : items) {
if (objects.contains(item.getData())) {
removeTableItem(item);
}
}
itemTable.setRedraw(true);
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method refreshCheckedTreeView.
private void refreshCheckedTreeView() {
List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
for (TableItem item : itemTable.getItems()) {
Object data = item.getData();
if (data instanceof RepositoryObject) {
nodes.add((RepositoryNode) ((RepositoryObject) data).getRepositoryNode());
}
}
treeViewer.setCheckedElements(nodes.toArray());
// treeViewer.refresh();
}
Aggregations