use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.
the class OpenDiagramAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean enabled = false;
if (!selection.isEmpty() && selection.size() == 1) {
Object object = selection.getFirstElement();
if (object instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) object;
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
if (nodeType == ERepositoryObjectType.BUSINESS_PROCESS) {
enabled = true;
}
}
if (enabled && (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
enabled = false;
}
RepositoryNode parent = repositoryNode.getParent();
if (enabled && parent != null && parent.isBin()) {
enabled = false;
}
}
}
setEnabled(enabled);
}
use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.
the class CreateDiagramAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
// PTODO mhelleboid refactor AContextualAction
repositoryNode = getRepositoryNode(selection);
boolean enabled = false;
if (repositoryNode != null) {
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
if (repositoryNode.getType() == RepositoryNode.ENodeType.SYSTEM_FOLDER || repositoryNode.getType() == RepositoryNode.ENodeType.SIMPLE_FOLDER) {
if (nodeType == ERepositoryObjectType.BUSINESS_PROCESS) {
enabled = true;
}
if (repositoryNode.getObject() != null && repositoryNode.getObject().isDeleted()) {
enabled = false;
}
}
}
if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
enabled = false;
}
if (enabled) {
enabled = ProjectManager.getInstance().isInCurrentMainProject(repositoryNode);
}
setEnabled(enabled);
}
use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.
the class AssignmentPropertySection method createRepositoryNode.
private RepositoryNode createRepositoryNode(BusinessAssignment businessAssignment) {
IRepositoryViewObject lastVersion;
try {
lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(businessAssignment.getTalendItem().getId());
if (lastVersion != null) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(lastVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(lastVersion, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(lastVersion), ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
return repositoryNode;
}
} catch (PersistenceException e) {
}
return null;
}
use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.
the class BusinessDiagramEditor method isLastVersion.
@Override
public boolean isLastVersion(Item item) {
if (lastVersion != null) {
return lastVersion;
}
if (item.getProperty() != null) {
try {
List<IRepositoryViewObject> allVersion = null;
ItemState state = item.getState();
ERepositoryObjectType type = ERepositoryObjectType.BUSINESS_PROCESS;
if (type != null && state != null && state.getPath() != null) {
allVersion = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAllVersion(item.getProperty().getId(), state.getPath(), type);
} else {
allVersion = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAllVersion(item.getProperty().getId());
}
if (allVersion == null || allVersion.isEmpty()) {
return false;
}
String lastVersion = VersionUtils.DEFAULT_VERSION;
for (IRepositoryViewObject object : allVersion) {
if (VersionUtils.compareTo(object.getVersion(), lastVersion) > 0) {
lastVersion = object.getVersion();
}
}
if (VersionUtils.compareTo(item.getProperty().getVersion(), lastVersion) == 0) {
return true;
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return false;
}
use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.
the class JSONRepositoryContentHandler method hideAction.
@Override
public boolean hideAction(IRepositoryNode node, Class actionType) {
boolean canHandle = false;
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (JSONRepositoryNodeType.JSON.equals(nodeType)) {
canHandle = true;
}
if (!canHandle) {
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType) || ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
RepositoryNode parentNode = node.getParent();
if (parentNode != null && JSONRepositoryNodeType.JSON.equals(parentNode.getProperties(EProperties.CONTENT_TYPE))) {
canHandle = true;
}
}
}
if (canHandle) {
if (actionType == CreateTableAction.class) {
return true;
}
}
return false;
}
Aggregations