use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class TableEditorManager method createLabelEditor.
public TableEditor createLabelEditor(TableEditor editor, Table table, String displayText, TableItem item, int column) {
if (editor == null) {
editor = new TableEditor(table);
editor.grabHorizontal = true;
addEditor(item, column, editor);
}
final Label label = new Label(table, SWT.NONE);
if (displayText != null) {
label.setText(displayText);
}
editor.setEditor(label, item, column);
addEditor(item, column, editor);
return editor;
}
use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class TableEditorManager method createComboEditor.
public TableEditor createComboEditor(Table table, String[] displayText, TableItem item, int column, int selectIndex, final IPropertySetter<Integer> accessor) {
TableEditor editor = new TableEditor(table);
final ColorCombo combo = new ColorCombo(table, SWT.READ_ONLY);
for (String text : displayText) {
combo.add(text);
}
if (accessor != null) {
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
accessor.set(combo.getSelectionIndex());
}
});
}
combo.select(selectIndex);
editor.grabHorizontal = true;
editor.setEditor(combo, item, column);
editor.minimumWidth = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
table.getColumn(column).setWidth(editor.minimumWidth);
addEditor(item, column, editor);
return editor;
}
use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method addItemElements.
private void addItemElements(List<RepositoryObject> elements) {
if (elements == null || elements.isEmpty()) {
return;
}
final Color redColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
for (final RepositoryObject object : elements) {
if (object.isDeleted()) {
continue;
}
TableItem tableItem = null;
// for bug 17692
ERepositoryObjectType objectType = object.getRepositoryNode().getObjectType();
ERepositoryObjectType type = object.getRepositoryNode().getContentType();
if (!objectType.equals(ERepositoryObjectType.JOB_DOC) && !objectType.equals(ERepositoryObjectType.JOBLET_DOC)) {
if (isTechinalStatus()) {
// obj.equals(constant) that will cause NPE.
if (!type.equals(ERepositoryObjectType.DOCUMENTATION) && !type.equals(ERepositoryObjectType.BUSINESS_PROCESS) && !type.equals(ERepositoryObjectType.JOBLET_DOC)) {
// if (!type.equals(ERepositoryObjectType.DOCUMENTATION) &&
// !type.equals(ERepositoryObjectType.BUSINESS_PROCESS)
// && !type.equals(ERepositoryObjectType.JOBLETS)) {
itemTable.setRedraw(false);
tableItem = new TableItem(itemTable, SWT.NONE);
}
} else if (isDocumentStatus()) {
if (type.equals(ERepositoryObjectType.DOCUMENTATION) || type.equals(ERepositoryObjectType.BUSINESS_PROCESS)) {
itemTable.setRedraw(false);
tableItem = new TableItem(itemTable, SWT.NONE);
}
} else // bug 20078
{
itemTable.setRedraw(false);
tableItem = new TableItem(itemTable, SWT.NONE);
}
} else {
if (isDocumentStatus()) {
if (type.equals(ERepositoryObjectType.JOB_DOC) || type.equals(ERepositoryObjectType.JOBLET_DOC)) {
itemTable.setRedraw(false);
tableItem = new TableItem(itemTable, SWT.NONE);
}
}
}
if (tableItem != null) {
tableItem.setData(object);
try {
statusHelper.getStatusList(object.getProperty());
} catch (PersistenceException e1) {
// TODO Auto-generated catch block
}
object.getProperty().setOldStatusCode(statusHelper.getStatusCode(object.getStatusCode()));
Image itemsImage = null;
IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
} else {
ERepositoryObjectType itemType = object.getRepositoryObjectType();
itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
}
tableItem.setImage(itemsImage);
tableItem.setText(object.getLabel());
// old version
tableItem.setText(1, statusHelper.getStatusLabel(object.getStatusCode()));
TableEditor versionEditor = null;
if (isFixedstatus()) {
String version = statusCombo.getText();
tableItem.setText(2, version);
if (!object.getProperty().getOldStatusCode().equals(statusHelper.getStatusCode(version))) {
tableItem.setForeground(2, redColor);
} else {
tableItem.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
}
} else {
// new version
versionEditor = new TableEditor(itemTable);
Composite versionComposit = new Composite(itemTable, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.horizontalSpacing = 1;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
versionComposit.setLayout(layout);
final CCombo statusItemCombo = new CCombo(versionComposit, SWT.BORDER | SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
statusItemCombo.setLayoutData(data);
statusItemCombo.setEditable(false);
if (!type.equals(ERepositoryObjectType.DOCUMENTATION) && !type.equals(ERepositoryObjectType.BUSINESS_PROCESS)) {
statusItemCombo.setItems(toArray(technicalStatusList));
statusItemCombo.select(0);
if (!object.getProperty().getOldStatusCode().equals("DEV")) {
statusItemCombo.setForeground(redColor);
} else {
statusItemCombo.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
}
} else {
statusItemCombo.setItems(toArray(documentStatusList));
statusItemCombo.select(0);
if (!object.getProperty().getOldStatusCode().equals("UCK")) {
statusItemCombo.setForeground(redColor);
} else {
statusItemCombo.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
}
}
statusItemCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String version = statusItemCombo.getText();
String status = statusHelper.getStatusCode(version);
if (!status.equals(object.getProperty().getOldStatusCode())) {
statusItemCombo.setForeground(redColor);
}
object.getProperty().setStatusCode(statusHelper.getStatusCode(version));
}
});
versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
versionEditor.setEditor(versionComposit, 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();
addLabelMouseListener(delLabel, object, tableItem);
delEditor.minimumWidth = 25;
delEditor.horizontalAlignment = SWT.CENTER;
delEditor.setEditor(delLabel, tableItem, 3);
if (isFixedstatus()) {
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 VersionManagementPage method addItemElements.
@Override
protected void addItemElements(List<ItemVersionObject> elements) {
if (elements == null || elements.isEmpty()) {
return;
}
itemTable.setRedraw(false);
final Color redColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
for (final ItemVersionObject object : elements) {
final TableItem tableItem = new TableItem(itemTable, SWT.NONE);
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, object.getOldVersion());
TableEditor versionEditor = null;
if (isFixedVersion()) {
String version = fixedVersionText.getText();
tableItem.setText(2, version);
if (VersionUtils.compareTo(version, object.getOldVersion()) > 0) {
tableItem.setForeground(2, redColor);
} else {
tableItem.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
}
} else {
// new version
versionEditor = new TableEditor(itemTable);
Composite versionComposit = new Composite(itemTable, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.horizontalSpacing = 1;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
versionComposit.setLayout(layout);
final Text text = new Text(versionComposit, SWT.BORDER | SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(data);
text.setEditable(false);
text.setText(object.getNewVersion());
if (VersionUtils.compareTo(object.getNewVersion(), object.getOldVersion()) > 0) {
text.setForeground(redColor);
} else {
text.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
}
Button tableMajorBtn = new Button(versionComposit, SWT.NONE);
//$NON-NLS-1$
tableMajorBtn.setText("M");
//$NON-NLS-1$
tableMajorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MajorVersionTip"));
Button tableMinorBtn = new Button(versionComposit, SWT.NONE);
//$NON-NLS-1$
tableMinorBtn.setText("m");
//$NON-NLS-1$
tableMinorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MinorVersionTip"));
tableMajorBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String version = object.getNewVersion();
version = VersionUtils.upMajor(version);
text.setText(version);
text.setForeground(redColor);
object.setNewVersion(version);
}
});
tableMinorBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String version = object.getNewVersion();
version = VersionUtils.upMinor(version);
text.setText(version);
text.setForeground(redColor);
object.setNewVersion(version);
}
});
versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
versionEditor.setEditor(versionComposit, 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 (isFixedVersion()) {
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 FunParaTableView2 method updateData.
private void updateData(List<Parameter> params) {
final Table table = this.getTable();
final TableViewer viewer = this.getTableViewerCreator().getTableViewer();
final TableEditor editor = new TableEditor(table);
// The editor must have the same size as the cell and must
// editing the Third column
final int eDITABLECOLUMN = 2;
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null) {
oldEditor.dispose();
}
// Identify the selected row
TableItem item = (TableItem) e.item;
if (item == null) {
return;
}
Parameter param = (Parameter) item.getData();
if (param instanceof ListParameter) {
createCombo((ListParameter) param, item);
}
}
private void createCombo(final ListParameter list, TableItem item) {
final CCombo combo = new CCombo(table, SWT.NONE);
combo.setItems(list.getValues());
combo.setFocus();
editor.setEditor(combo, item, eDITABLECOLUMN);
combo.setText(list.getValue());
Point size = combo.computeSize(SWT.DEFAULT, table.getItemHeight());
// Set attributes of the editor
editor.horizontalAlignment = SWT.LEFT;
editor.minimumHeight = size.y;
editor.minimumWidth = size.x;
combo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
list.setValue(combo.getText());
viewer.refresh(list);
ext.setChanged(true);
rowGenTableEditor2.getTableViewerCreator().getTableViewer().refresh();
}
});
combo.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
/**
* Sent when a control loses focus.
*
* @param e an event containing information about the focus change
*/
public void focusLost(FocusEvent e) {
combo.dispose();
}
});
}
});
getTableViewerCreator().setInputList(params);
}
Aggregations