use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.
the class FixUnevenItemContextParametersMigrationTaskTest method testAfter.
@After
public void testAfter() throws PersistenceException, BusinessException {
RepositoryObject objToDelete = new RepositoryObject(testItem.getProperty());
ProxyRepositoryFactory.getInstance().deleteObjectPhysical(objToDelete);
testItem = null;
}
use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method processItems.
private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
if (node == null) {
return;
}
// if the root node of type is not init, force init.
IProjectRepositoryNode root = node.getRoot();
if (root instanceof ProjectRepositoryNode) {
((ProjectRepositoryNode) root).initNode(node);
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (node.getObject() != null) {
Property property = node.getObject().getProperty();
Item item = property.getItem();
if (item != null && filterRepositoryNode((RepositoryNode) node)) {
// must be item
RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
object.setRepositoryNode(node);
// ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
objects.add(object);
}
}
} else {
IContentProvider contentProvider = treeViewer.getContentProvider();
if (contentProvider instanceof NavigatorContentServiceContentProvider) {
NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
Object[] children = navigatorProvider.getChildren(node);
for (Object child : children) {
if (child instanceof RepositoryNode) {
processItems(objects, (RepositoryNode) child);
}
}
} else {
for (IRepositoryNode child : node.getChildren()) {
processItems(objects, child);
}
}
}
}
use of org.talend.core.model.repository.RepositoryObject 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.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method addRepositoryTreeViewer.
/**
* repository tree viewer.
*/
private void addRepositoryTreeViewer(Composite leftComposite) {
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = 210;
gridData.heightHint = 400;
leftComposite.setLayoutData(gridData);
RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
treeViewer = (CheckboxRepositoryTreeViewer) provider.createViewer(leftComposite);
// filter
treeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
RepositoryNode node = (RepositoryNode) element;
return filterRepositoryNode(node);
}
});
// event
treeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
RepositoryNode node = (RepositoryNode) event.getElement();
List<RepositoryObject> objects = new ArrayList<RepositoryObject>();
processItems(objects, node);
if (!objects.isEmpty()) {
if (event.getChecked()) {
checkedObjects.addAll(objects);
} else {
checkedObjects.removeAll(objects);
removeItemElements(objects);
}
// researchMaxVersion();
refreshTableItems();
}
}
});
treeViewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
//
}
@Override
public void treeExpanded(TreeExpansionEvent event) {
// refreshCheckedTreeView();
}
});
expandSomeNodes(provider.getProjectRepositoryNode());
}
use of org.talend.core.model.repository.RepositoryObject in project tbd-studio-se by Talend.
the class HDFSModelUtilTest method tearDown.
@After
public void tearDown() throws PersistenceException {
factory.deleteObjectPhysical(new RepositoryObject(contextItem.getProperty()));
factory.deleteObjectPhysical(new RepositoryObject(hcConnectionItem.getProperty()));
}
Aggregations