use of org.talend.repository.model.ItemVersionObject 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.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.
the class VersionManagementPage method researchMaxVersion.
protected void researchMaxVersion() {
String version = fixedVersionText.getText();
if ("".equals(version.trim())) {
//$NON-NLS-1$
version = VersionUtils.DEFAULT_VERSION;
}
for (ItemVersionObject object : checkedObjects) {
if (VersionUtils.compareTo(version, object.getOldVersion()) < 0) {
version = object.getOldVersion();
}
}
fixedVersionText.setText(version);
}
use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.
the class ItemsVersionConfirmDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
TableViewer viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.minimumHeight = 200;
data.heightHint = 200;
data.minimumWidth = 350;
data.widthHint = 350;
viewer.getControl().setLayoutData(data);
final Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("VersionManagementDialog.Items"));
column.setWidth(140);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("ItemsVersionChangedDialog.OriginalVersion"));
column.setWidth(120);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("VersionManagementDialog.NewVersion"));
column.setWidth(90);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
ItemVersionObject object = (ItemVersionObject) element;
if (columnIndex == 0) {
return ImageProvider.getImage(CoreImageProvider.getIcon(object.getItem()));
}
return null;
}
public String getColumnText(Object element, int columnIndex) {
ItemVersionObject object = (ItemVersionObject) element;
switch(columnIndex) {
case 0:
return object.getItem().getProperty().getLabel();
case 1:
return object.getOldVersion();
case 2:
if (object.getOldVersion().equals(object.getNewVersion())) {
//$NON-NLS-1$
return "-";
}
return object.getNewVersion();
default:
}
return null;
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
viewer.setInput(modifiedVersionItems);
for (TableItem item : table.getItems()) {
ItemVersionObject object = (ItemVersionObject) item.getData();
if (!object.getOldVersion().equals(object.getNewVersion())) {
item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
}
}
return composite;
}
use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method createItemVersionObject.
@Override
protected ItemVersionObject createItemVersionObject(RepositoryNode node, Property property) {
String version = MavenVersionUtils.getItemMavenVersion(property);
ItemVersionObject object = new ItemVersionObject(property, node, version);
return object;
}
use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method checkButtonsState.
protected void checkButtonsState(boolean isEnable) {
boolean flag = isEnable;
TableItem[] items = itemTable.getItems();
for (TableItem item : items) {
if (item.getData() instanceof ItemVersionObject) {
ItemVersionObject itemVersionObj = (ItemVersionObject) item.getData();
RepositoryNode repositoryNode = itemVersionObj.getRepositoryNode();
if (repositoryNode != null) {
ERepositoryObjectType type = repositoryNode.getContentType();
if (MavenVersionUtils.isVersioningType(type)) {
flag = true;
break;
}
}
}
}
if (alldependcies != null) {
alldependcies.setEnabled(flag);
}
if (subjobs != null) {
subjobs.setEnabled(flag);
}
}
Aggregations