use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.
the class CopyAction method doRun.
protected void doRun() {
ITreeSelection selection = (ITreeSelection) getStructuredSelection();
List<TreePath> paths = new ArrayList<TreePath>(selection.getPaths().length);
for (TreePath path : selection.getPaths()) {
Object lastObj = path.getLastSegment();
if (lastObj instanceof WSRootRepositoryObject) {
continue;
}
if (lastObj instanceof FolderRepositoryObject) {
continue;
}
paths.add(path);
}
selection = new TreeSelection(paths.toArray(new TreePath[] {}));
LocalSelectionTransfer.getTransfer().setSelection(selection);
}
use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method assertViewObject.
public static IRepositoryViewObject assertViewObject(IRepositoryViewObject viewObj) {
if (viewObj == null) {
throw new IllegalArgumentException();
}
if (viewObj instanceof IRepositoryViewObject && !(viewObj instanceof FolderRepositoryObject || viewObj instanceof WSRootRepositoryObject) && viewObj instanceof RepositoryObject) {
boolean reload = false;
Property property = viewObj.getProperty();
if (property != null) {
Item item = property.getItem();
Resource eResource = item.eResource();
reload = eResource == null || eResource.getResourceSet() == null;
} else {
reload = true;
}
if (reload) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
try {
IRepositoryViewObject newViewObj = factory.getLastVersion(viewObj.getId());
property = viewObj.getProperty();
if (property != null) {
Item item = property.getItem();
Resource eResource = item.eResource();
reload = eResource == null || eResource.getResourceSet() == null;
if (reload) {
if (property.eResource() != null && property.eResource().getURI() != null) {
property = factory.reload(property);
newViewObj = new RepositoryViewObject(property);
} else {
log.error(// $NON-NLS-1$
"Can not reload property " + property.getLabel() + // $NON-NLS-1$
", because property.eResource is null or eResource.getURI is null");
}
}
}
if (newViewObj != null) {
ContainerCacheService.put(newViewObj);
return newViewObj;
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
}
return viewObj;
}
use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.
the class OpenObjectAction method doOpen.
public boolean doOpen() {
List<Object> sels = getSelectedObject();
if (selObjects != null) {
sels = selObjects;
}
if (sels.isEmpty()) {
return false;
}
Object obj = sels.get(0);
if (obj instanceof IRepositoryViewObject) {
if (obj instanceof WSRootRepositoryObject) {
return false;
}
IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
Item item = viewObject.getProperty().getItem();
if (item instanceof ContainerItem) {
if (viewObject.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_SERVICECONFIGURATION)) {
// service
boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
if (!checkMissingJar) {
return false;
}
// configuration
MDMServerDef serverDef = openServerDialog(null);
openServiceConfig(serverDef);
} else {
getCommonViewer().expandToLevel(obj, 1);
}
} else {
IEditorReference editorRef = RepositoryResourceUtil.isOpenedInEditor(viewObject);
if (editorRef != null) {
if (page == null) {
page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
}
if (page != null) {
page.bringToTop(editorRef.getPart(false));
}
if (marker != null) {
IDE.gotoMarker(editorRef.getEditor(true), marker);
}
return false;
} else {
openItem(viewObject);
return true;
}
}
}
return true;
}
use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method adapt2ResourceElement.
public static Object[] adapt2ResourceElement(IRepositoryViewObject viewObj) {
if (viewObj == null) {
return null;
}
try {
if (viewObj instanceof WSRootRepositoryObject) {
Project project = ProjectManager.getInstance().getCurrentProject();
IProject prj = ResourceUtils.getProject(project);
return new Object[] { prj };
} else {
ERepositoryObjectType type = viewObj.getRepositoryObjectType();
if (viewObj instanceof FolderRepositoryObject) {
if (type == IServerObjectRepositoryType.TYPE_EVENTMANAGER) {
return new Object[] { getFolder(IServerObjectRepositoryType.TYPE_TRANSFORMERV2), getFolder(IServerObjectRepositoryType.TYPE_ROUTINGRULE) };
} else {
return new Object[] { getFolder(viewObj) };
}
} else {
Item item = viewObj.getProperty().getItem();
// $NON-NLS-1$
IFile itemFile = findReferenceFile(type, item, "item");
if (type == IServerObjectRepositoryType.TYPE_DATAMODEL) {
// $NON-NLS-1$
IFile xsdFile = findReferenceFile(type, item, "xsd");
return new Object[] { xsdFile, itemFile };
} else if (type == IServerObjectRepositoryType.TYPE_WORKFLOW) {
// $NON-NLS-1$
IFile configFile = findReferenceFile(type, item, "conf");
return new Object[] { configFile };
} else {
return new Object[] { itemFile };
}
}
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
return null;
}
use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method getCategoryViewObjectsWithRecycle.
public static IRepositoryViewObject[] getCategoryViewObjectsWithRecycle() {
if (rootViewObj == null) {
//
rootViewObj = null;
Property prop = PropertiesFactory.eINSTANCE.createProperty();
prop.setId(EcoreUtil.generateUUID());
ItemState state = PropertiesFactory.eINSTANCE.createItemState();
WorkspaceRootItem item = MdmpropertiesFactory.eINSTANCE.createWorkspaceRootItem();
item.setState(state);
prop.setItem(item);
rootViewObj = new WSRootRepositoryObject(prop);
//
IRepositoryViewObject[] cvos = getCategoryViewObjects();
List<IRepositoryViewObject> newViewObjs = rootViewObj.getChildren();
for (IRepositoryViewObject viewObj : cvos) {
newViewObjs.add(viewObj);
}
//
newViewObjs.add(getCategoryViewObject(RepositoryNodeConfigurationManager.getRecycleBinNodeConfiguration()));
}
return new IRepositoryViewObject[] { rootViewObj };
}
Aggregations