use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method isOpenedInEditor.
public static IEditorReference isOpenedInEditor(IRepositoryViewObject viewObj) {
IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (IEditorReference ref : editorReferences) {
if (ref != null) {
try {
IEditorInput editorInput = ref.getEditorInput();
if (editorInput instanceof IRepositoryViewEditorInput) {
Item inputItem = ((IRepositoryViewEditorInput) editorInput).getInputItem();
if (inputItem != null) {
IRepositoryViewObject vObj = ContainerCacheService.get(inputItem.getProperty());
if (vObj != null && vObj.equals(viewObj)) {
return ref;
}
}
}
if (exAdapter != null) {
IEditorReference wfEditor = exAdapter.getOpenedWFEditor(viewObj, ref);
if (wfEditor != null) {
return wfEditor;
}
}
if (editorInput instanceof ProcessEditorInput) {
ProcessEditorInput processEditorInput = (ProcessEditorInput) editorInput;
Property property = processEditorInput.getItem().getProperty();
if (viewObj.getProperty().getId().equals(property.getId())) {
return ref;
}
}
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
}
}
return null;
}
use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.
the class LockedDirtyObjectDialog method isDirtyMdmViewObj.
private boolean isDirtyMdmViewObj(List<IRepositoryViewObject> inputObjs, IRepositoryViewObject viewObj) {
if (editorRefMap == null) {
editorRefMap = new HashMap<String, IEditorPart>();
// collect all ids
Set<String> ids = new HashSet<String>();
for (IRepositoryViewObject viewObject : inputObjs) {
String id = viewObject.getId();
if (id != null) {
ids.add(id);
}
}
//
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
for (IEditorReference ref : activePage.getEditorReferences()) {
try {
String id = null;
IEditorInput editorInput = ref.getEditorInput();
if (editorInput instanceof IRepositoryViewEditorInput) {
IRepositoryViewObject viewObject = ((IRepositoryViewEditorInput) editorInput).getViewObject();
if (viewObject != null) {
id = viewObject.getId();
}
} else if (editorInput instanceof ProcessEditorInput) {
id = ((ProcessEditorInput) editorInput).getId();
}
if (id != null && ids.contains(id)) {
IEditorPart editor = ref.getEditor(false);
if (editor != null && editor.isDirty()) {
editorRefMap.put(id, editor);
}
}
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
}
}
}
return editorRefMap.containsKey(viewObj.getId());
}
use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.
the class OpenObjectAction method openItem.
private void openItem(IRepositoryViewObject viewObject) {
Item item = viewObject.getProperty().getItem();
item = RepositoryResourceUtil.assertItem(item);
IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
if (configuration != null) {
IRepositoryNodeActionProvider actionProvider = configuration.getActionProvider();
if (actionProvider != null) {
IRepositoryViewEditorInput editorInput = actionProvider.getOpenEditorInput(viewObject);
if (editorInput != null) {
if (page == null) {
this.page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
}
// do extra action
MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
if (!checkMissingJar(serverObject)) {
return;
}
boolean selected = doSelectServer(item, editorInput);
if (!selected) {
return;
}
try {
// svn lock
ERepositoryStatus status = factory.getStatus(item);
boolean isEditable = factory.isEditableAndLockIfPossible(item);
if (isEditable) {
getCommonViewer().refresh(viewObject);
}
//
editorInput.setReadOnly(status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.READ_ONLY || !isEditable);
if (!editorInput.isReadOnly()) {
editorInput.setReadOnly(item.getState().isDeleted());
}
updateEditorInputVersionInfo(editorInput, viewObject);
activeEditor = this.page.openEditor(editorInput, editorInput.getEditorId());
if (marker != null) {
IDE.gotoMarker(activeEditor, marker);
}
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
} else {
AbstractRepositoryAction openAction = actionProvider.getOpenAction(viewObject);
if (openAction != null) {
openAction.selectionChanged(getStructuredSelection());
openAction.run();
}
}
}
}
}
use of org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method closeEditor.
public static void closeEditor(IRepositoryViewObject viewObj, boolean save) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
for (IEditorReference ref : editorReferences) {
if (ref != null) {
try {
IEditorInput editorInput = ref.getEditorInput();
if (editorInput instanceof IRepositoryViewEditorInput) {
Item inputItem = ((IRepositoryViewEditorInput) editorInput).getInputItem();
if (inputItem != null) {
IRepositoryViewObject vObj = ContainerCacheService.get(inputItem.getProperty());
if (vObj != null && vObj.equals(viewObj)) {
activePage.closeEditors(new IEditorReference[] { ref }, save);
}
}
}
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
}
}
}
Aggregations