use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryNodeActionProviderAdapter method getActions.
@Override
public List<AbstractRepositoryAction> getActions(IRepositoryViewObject viewObj) {
List<AbstractRepositoryAction> actions = new LinkedList<AbstractRepositoryAction>();
//
Item item = viewObj.getProperty().getItem();
if (item instanceof MDMItem) {
if (item instanceof ContainerItem) {
FolderType type = ((FolderItem) item).getType();
switch(type.getValue()) {
case FolderType.SYSTEM_FOLDER:
addAction(actions, createFolderAction, viewObj);
addAction(actions, pasteAction, viewObj);
actions.add(importServerObjectAction);
actions.add(importObjectAction);
break;
case FolderType.STABLE_SYSTEM_FOLDER:
break;
case FolderType.FOLDER:
addAction(actions, createFolderAction, viewObj);
if (!((ContainerItem) item).getRepObjType().equals(ERepositoryObjectType.PROCESS)) {
actions.add(removeFromRepositoryAction);
}
addAction(actions, pasteAction, viewObj);
break;
}
} else if (item instanceof MDMServerObjectItem) {
addAction(actions, removeFromRepositoryAction, viewObj);
addAction(actions, mdmEditPropertyAction, viewObj);
addAction(actions, openVersionAction, viewObj);
addAction(actions, copyAction, viewObj);
addAction(actions, pasteAction, viewObj);
addAction(actions, duplicateAction, viewObj);
if (exAdapter != null) {
exAdapter.addActions(actions, viewObj);
}
} else if (item instanceof WorkspaceRootItem) {
// fix bug TMDM-3168
actions.add(importObjectAction);
}
}
if (enableDebug) {
// for debug digestValue
addAction(actions, debugDigestValueAction, viewObj);
}
//
actions.add(refreshAction);
actions.add(exportObjectAction);
// action provider
for (IRepositoryNodeActionProvider provider : getExtendActionProviders()) {
List<AbstractRepositoryAction> providerActions = provider.getActions(viewObj);
if (providerActions != null) {
actions.addAll(providerActions);
}
}
if (viewObj.getRepositoryObjectType() != null && IServerObjectRepositoryType.TYPE_EVENTMANAGER.equals(viewObj.getRepositoryObjectType())) {
actions.add(emAction);
}
//
return actions;
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class CreateFolderAction method doRun.
@Override
protected void doRun() {
Object object = getSelectedObject().get(0);
if (object != null && object instanceof FolderRepositoryObject) {
final FolderRepositoryObject containerViewObject = (FolderRepositoryObject) object;
InputDialog dlg = new InputDialog(getShell(), Messages.CreateFolderAction_newCategory, Messages.CreateFolderAction_inputCategoryName, null, new IInputValidator() {
public String isValid(String newText) {
if ((newText == null) || "".equals(newText)) {
return Messages.Common_nameCanNotBeEmpty;
}
// $NON-NLS-1$
Pattern p = Pattern.compile("([\\s*|\\W*]+)");
Matcher m = p.matcher(newText);
if (m.find()) {
m.group(1);
return Messages.Common_nameInvalid;
}
if (RepositoryResourceUtil.isDeletedFolder(containerViewObject.getRepositoryObjectType(), containerViewObject, newText)) {
return Messages.Common_nameIsUsed;
}
for (IRepositoryViewObject viewObj : containerViewObject.getChildren()) {
Item item = viewObj.getProperty().getItem();
if (item instanceof ContainerItem) {
if (((ContainerItem) item).getLabel().equals(newText)) {
return Messages.CreateFolderAction_nameIsUsed;
}
}
}
return null;
}
});
dlg.setBlockOnOpen(true);
if (dlg.open() == Window.CANCEL) {
return;
}
String categoryName = dlg.getValue();
//
if (categoryName != null) {
IRepositoryViewObject folderViewObject = RepositoryResourceUtil.createFolderViewObject(containerViewObject.getRepositoryObjectType(), categoryName, containerViewObject.getProperty().getItem(), false);
containerViewObject.getChildren().add(folderViewObject);
commonViewer.refresh(containerViewObject);
commonViewer.expandToLevel(containerViewObject, 1);
}
}
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryNodeConfigurationManager method getConfiguration.
public static IRepositoryNodeConfiguration getConfiguration(Item item) {
EClass eClass = item.eClass();
IRepositoryNodeConfiguration configuration = itemConfMap.get(eClass);
if (configuration != null) {
return configuration;
}
for (IRepositoryNodeConfiguration conf : getConfigurations()) {
IRepositoryNodeResourceProvider resourceProvider = conf.getResourceProvider();
if (resourceProvider != null) {
if (resourceProvider.canHandleItem(item)) {
if (!(item instanceof ContainerItem)) {
itemConfMap.put(eClass, conf);
}
return conf;
}
}
}
if (recycleBinNodeConfiguration.getResourceProvider().canHandleItem(item)) {
return recycleBinNodeConfiguration;
}
return null;
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method convertToNode.
public static RepositoryNode convertToNode(IRepositoryViewObject viewObj) {
Item item = viewObj.getProperty().getItem();
ENodeType type = ENodeType.REPOSITORY_ELEMENT;
if (item instanceof ContainerItem) {
FolderType folderType = ((ContainerItem) item).getType();
switch(folderType.getValue()) {
case FolderType.SYSTEM_FOLDER:
type = ENodeType.SYSTEM_FOLDER;
break;
case FolderType.STABLE_SYSTEM_FOLDER:
type = ENodeType.STABLE_SYSTEM_FOLDER;
break;
case FolderType.FOLDER:
type = ENodeType.SIMPLE_FOLDER;
break;
default:
break;
}
}
ERepositoryObjectType repObjType = viewObj.getRepositoryObjectType();
RepositoryNode node = new MDMRepositoryNode(viewObj, null, type);
node.setProperties(EProperties.LABEL, viewObj.getLabel());
node.setProperties(EProperties.CONTENT_TYPE, repObjType);
addChildrenToNode(viewObj, node);
return node;
}
use of org.talend.mdm.repository.model.mdmproperties.ContainerItem in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method isDeletedFolder.
public static boolean isDeletedFolder(Item item, ERepositoryObjectType type) {
ItemState state = item.getState();
if (item instanceof ContainerItem) {
String path = ERepositoryObjectType.getFolderName(type);
if (!path.isEmpty()) {
path += state.getPath();
}
List<String> deletedFolderPaths = ProjectManager.getInstance().getCurrentProject().getEmfProject().getDeletedFolders();
return deletedFolderPaths.contains(path);
} else {
return state.isDeleted();
}
}
Aggregations