use of org.eclipse.swt.custom.TableEditor in project cogtool by cogtool.
the class DictionaryEditorUIModel method createEmptyRow.
public TableItem createEmptyRow(int index) {
final TableItem emptyRow = new TableItem(dictTable, SWT.NONE, index);
emptyRow.setText(GOAL_COL, "");
emptyRow.setText(SEARCH_COL, "");
emptyRow.setText(SIMIL_COL, "");
emptyRow.setText(DATE_COL, "");
TableEditor editor = new TableEditor(dictTable);
editor.grabHorizontal = true;
Combo algCombo = createAlgCombo(dictTable, dictionary.getCurrentAlgorithm(), algListener);
algCombo.setData(emptyRow);
emptyRow.setData(algCombo);
editor.setEditor(algCombo, emptyRow, 3);
return emptyRow;
}
use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class MultipleSurrogateSection method initTableItem.
/**
* DOC hcw Comment method "initTableItem".
*
* @param key
* @param item
*/
private void initTableItem(final SurrogateKey key, final TableItem item) {
item.setData(key);
// text editor
TableEditor editor = editorManager.createTextEditor(table, key.getColumn(), item, COLUMN_INDEX, new IPropertySetter<String>() {
public void set(String value) {
key.setColumn(value);
}
});
// combo editor
// final List<String> outputColumns = scdManager.getOutputColumnNames();
// int index = editorManager.getComboIndex(outputColumns, key.getColumn());
// final TableEditor editor = editorManager.createComboEditor(table,
// outputColumns.toArray(new String[outputColumns.size()]), item, COLUMN_INDEX, index,
// new IPropertySetter<Integer>() {
//
// public void set(Integer value) {
// key.setColumn(outputColumns.get(value));
// }
// });
editor.layout();
TableEditor comboEditor = editorManager.createComboEditor(table, getScdManager().getSurrogateCreationTypeNames(), item, CREATION_INDEX, key.getCreation().getIndex(), new IPropertySetter<Integer>() {
public void set(Integer value) {
key.setCreation(SurrogateCreationType.getTypeByIndex(value));
// remove value from model
//$NON-NLS-1$
key.setComplement("");
creationComplement(value, key, item);
}
});
creationComplement(key.getCreation().getIndex(), key, item);
}
use of org.eclipse.swt.custom.TableEditor 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.custom.TableEditor in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method removeTableItem.
private void removeTableItem(TableItem item) {
if (item == null) {
return;
}
TableEditor[] editors = (TableEditor[]) item.getData(ITEM_EDITOR_KEY);
if (editors != null) {
for (TableEditor editor : editors) {
editor.getEditor().dispose();
editor.dispose();
}
}
item.dispose();
}
use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class PromptDefaultValueDialog method createComboEditor.
private void createComboEditor(TableItem item, int column, String[] displayText, int selectIndex) {
TableEditor editor = new TableEditor(table);
final CCombo combo = new CCombo(table, SWT.READ_ONLY);
for (String text : displayText) {
combo.add(text);
}
combo.select(selectIndex);
editor.grabHorizontal = true;
editor.setEditor(combo, item, column);
// editor.minimumWidth = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
editor.layout();
editors.add(editor);
}
Aggregations