use of org.eclipse.jface.viewers.IBaseLabelProvider in project tdi-studio-se by Talend.
the class NameAndLabelsTreeController method createControl.
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
Composite parentComp = new Composite(subComposite, SWT.NONE);
parentComp.setLayoutData(data);
parentComp.setLayout(new GridLayout());
ElementsSelectionComposite<NamedThing> selectionComposite = new ElementsSelectionComposite<NamedThing>(parentComp) {
@Override
protected IBaseLabelProvider getLabelProvider() {
return new LabelProvider() {
@Override
public String getText(Object obj) {
NamedThing nal = (NamedThing) obj;
return nal.getDisplayName();
}
@Override
public Image getImage(Object obj) {
return null;
}
};
}
;
@Override
protected void doSelectionChanged() {
param.setValue(getSelectedElements());
}
@Override
protected List<String> getSelectedElementLabels() {
List<String> labels = new ArrayList<>();
Object value = param.getValue();
if (value instanceof List) {
List<?> values = (List<?>) value;
for (Object valueObj : values) {
if (valueObj instanceof NamedThing) {
labels.add(((NamedThing) valueObj).getName());
}
}
return labels;
}
return null;
}
@Override
protected List<NamedThing> getInitSelectedElements(List<String> selectedElementLabels) {
List<NamedThing> selectedElements = new ArrayList<>();
List<NamedThing> viewerDatas = getViewerData();
for (NamedThing viewerData : viewerDatas) {
if (selectedElementLabels.contains(viewerData.getName())) {
selectedElements.add(viewerData);
}
}
return selectedElements;
}
}.setShowToolbar(true).create();
selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
if (param instanceof GenericElementParameter) {
selectionComposite.setViewerData(ComponentsUtils.getFormalPossibleValues((GenericElementParameter) param));
}
selectionComposite.setCheckedState();
return parentComp;
}
use of org.eclipse.jface.viewers.IBaseLabelProvider in project tdi-studio-se by Talend.
the class NameAndLabelsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Composite comp = new Composite(composite, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
comp.setLayout(new GridLayout());
selectionComposite = new ElementsSelectionComposite<NamedThing>(comp) {
@Override
protected IBaseLabelProvider getLabelProvider() {
return new LabelProvider() {
@Override
public String getText(Object obj) {
NamedThing nal = (NamedThing) obj;
return nal.getDisplayName();
}
@Override
public Image getImage(Object obj) {
return null;
}
};
}
;
}.setMultipleSelection(false).create();
selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
selectionComposite.setViewerData(nameAndLabels);
Composite customComposite = new Composite(comp, SWT.NONE);
customComposite.setLayout(new GridLayout());
customComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button useCustomBtn = new Button(customComposite, SWT.CHECK);
//$NON-NLS-1$
useCustomBtn.setText(Messages.getString("NameAndLabelsDialog.custom.button"));
useCustomBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateFieldsStatus(useCustomBtn.getSelection());
}
});
//$NON-NLS-1$
customObjNameText = new LabelledText(customComposite, Messages.getString("NameAndLabelsDialog.custom.text"));
updateFieldsStatus(useCustomBtn.getSelection());
if (!isInWizard) {
// set empty quotes to show the user he should fill the name between quotes
//$NON-NLS-1$
customObjNameText.setText("\"\"");
}
return composite;
}
use of org.eclipse.jface.viewers.IBaseLabelProvider 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.jface.viewers.IBaseLabelProvider 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.jface.viewers.IBaseLabelProvider 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);
}
}
Aggregations