use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class NewDataModelAction method run.
public void run(IIntroSite site, Properties params) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
MessageDialog.openWarning(null, Messages.NewDataModelAction_UserAuthority, Messages.NewDataModelAction_CanNotCreateModel);
} else {
PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!IBrandingConfiguration.PERSPECTIVE_MDM_ID.equals(currentPerspective.getId())) {
// show mdm perspective
try {
workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_MDM_ID, workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return;
}
}
//
// $NON-NLS-1$
IRepositoryViewObject folderViewObj = ContainerCacheService.get(IServerObjectRepositoryType.TYPE_DATAMODEL, "");
selectObj = folderViewObj;
if (folderViewObj != null && folderViewObj instanceof FolderRepositoryObject) {
Item pItem = folderViewObj.getProperty().getItem();
if (pItem instanceof ContainerItem) {
setParentItem((ContainerItem) pItem);
}
}
run();
}
}
use of org.talend.mdm.repository.models.FolderRepositoryObject 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.FolderRepositoryObject 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.models.FolderRepositoryObject in project tmdm-studio-se by Talend.
the class ContainerCacheService method removeContainer.
public static void removeContainer(ERepositoryObjectType repObjType, String path) {
Map<String, IRepositoryViewObject> map = containerMap.get(repObjType);
if (map != null) {
for (Iterator<String> il = map.keySet().iterator(); il.hasNext(); ) {
String next = il.next();
if (next.startsWith(path)) {
IRepositoryViewObject viewObj = map.get(next);
if (viewObj != null && viewObj instanceof FolderRepositoryObject) {
if (viewObj.getChildren() != null) {
for (IRepositoryViewObject child : viewObj.getChildren()) {
remove(child.getProperty());
}
}
}
il.remove();
}
}
}
}
use of org.talend.mdm.repository.models.FolderRepositoryObject 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;
}
Aggregations