use of org.talend.designer.business.diagram.custom.commands.ChangeTalendItemLabelCommand in project tdi-studio-se by Talend.
the class RepositoryFactoryProxyLabelProvider method getColumnText.
@Override
public String getColumnText(Object object, int columnIndex) {
String columnText = super.getColumnText(object, columnIndex);
BusinessAssignment assignment = (BusinessAssignment) object;
IRepositoryViewObject lastVersion = getLastVersion(object);
try {
if (columnIndex == 0) {
if (lastVersion == null) {
MetadataTable table = MetadataToolHelper.getMetadataTableFromRepository(assignment.getTalendItem().getId());
if (table != null) {
if (SubItemHelper.isDeleted(table)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
return columnText;
}
Query query = MetadataToolHelper.getQueryFromRepository(assignment.getTalendItem().getId());
if (query != null) {
if (SubItemHelper.isDeleted(query)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
return columnText;
}
SAPFunctionUnit function = MetadataToolHelper.getSAPFunctionFromRepository(assignment.getTalendItem().getId());
if (function != null) {
if (SubItemHelper.isDeleted(function)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
return columnText;
}
TalendItem item = assignment.getTalendItem();
if (item instanceof SQLPattern) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SQLPATTERNS);
for (IRepositoryViewObject obj : list) {
if (item.getLabel().equals(obj.getLabel())) {
return columnText;
}
}
} else if (item instanceof Routine) {
List<IRepositoryViewObject> list = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.ROUTINES);
for (IRepositoryViewObject obj : list) {
if (item.getLabel().equals(obj.getLabel())) {
return columnText;
}
}
}
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.NotFound");
} else if (isDeleted(lastVersion)) {
//$NON-NLS-1$
columnText += Messages.getString("RepositoryFactoryProxyLabelProvider.Deleted");
}
}
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
if (columnIndex == 1) {
if (lastVersion != null) {
String label = lastVersion.getProperty().getLabel();
if (!label.equals(columnText)) {
ChangeTalendItemLabelCommand command = new ChangeTalendItemLabelCommand(((BusinessAssignment) object).getTalendItem(), label);
try {
command.execute(null, null);
} catch (ExecutionException e) {
}
return label;
}
}
}
return columnText;
}
Aggregations