use of org.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.
the class UpdateLastServerCommand method saveLastServer.
private void saveLastServer(Item item, MDMServerDef serverDef) {
if (item.eResource() == null) {
try {
IRepositoryViewObject viewObj = factory.getLastVersion(item.getProperty().getId());
if (viewObj == null) {
// when object is match rule map info object,it must not exist and return null
return;
}
Property property = viewObj.getProperty();
item = property.getItem();
ContainerCacheService.put(property, viewObj);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
RepositoryResourceUtil.setLastServerDef(item, serverDef);
if (!(item instanceof ProcessItem)) {
// for common object except job
try {
factory.save(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
} else {
if (isWorkInUI()) {
// for job object
try {
RepositoryViewObjectResourceChangeManager.stopListening();
IEditorReference editorRef = getJobEditor(item);
if (editorRef != null) {
IEditorPart editor = editorRef.getEditor(false);
if (editor != null && editor.isDirty()) {
// when save job editor, it only keep the additional properties that Process have
ProcessEditorInput processEditorInput = (ProcessEditorInput) editor.getEditorInput();
EMap additionalProperties = item.getProperty().getAdditionalProperties();
Iterator iterator = additionalProperties.keySet().iterator();
Map<Object, Object> processAdditionalProperties = processEditorInput.getLoadedProcess().getAdditionalProperties();
processAdditionalProperties.putAll(additionalProperties.map());
editor.doSave(new NullProgressMonitor());
return;
}
}
factory.save(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} finally {
RepositoryViewObjectResourceChangeManager.startListening();
}
} else {
// save under command line
try {
factory.save(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
}
}
use of org.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.
the class NewProcessAction method refreshJobEditorTitle.
private void refreshJobEditorTitle(Item item) {
String label = item.getProperty().getLabel();
// job name can not contains '#' and '$', see job's create procedure
// $NON-NLS-1$ //$NON-NLS-2$
label = label.replaceAll("#|\\$", "");
IWorkbenchPage activePage = getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
if (editorReferences != null) {
for (IEditorReference editorPart : editorReferences) {
IEditorInput editorInput = editorPart.getEditor(false).getEditorInput();
if (editorInput instanceof ProcessEditorInput) {
ProcessEditorInput processInput = (ProcessEditorInput) editorInput;
ProcessItem jobItem = (ProcessItem) processInput.getItem();
MultiPageTalendEditor jobEditor = (MultiPageTalendEditor) editorPart.getEditor(false);
String jobLabel = jobItem.getProperty().getLabel();
if (jobLabel.equals(label)) {
jobEditor.refreshName();
break;
}
}
}
}
}
use of org.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.
the class RemoveFromRepositoryAction method removeServerObject.
private void removeServerObject(IRepositoryViewObject viewObj) {
if (removed.contains(viewObj.getId())) {
return;
}
removed.add(viewObj.getId());
try {
Item item = viewObj.getProperty().getItem();
IEditorReference ref = RepositoryResourceUtil.isOpenedInEditor(viewObj);
if (ref != null) {
RepositoryResourceUtil.closeEditor(ref, true);
}
factory.deleteObjectLogical(viewObj);
if (item instanceof MDMServerObjectItem) {
MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
CommandManager.getInstance().pushCommand(ICommand.CMD_DELETE, viewObj.getId(), serverObj.getName());
}
} catch (BusinessException e) {
MessageDialog.openError(getShell(), Messages.Common_Error, e.getMessage());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.eclipse.ui.IEditorReference 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.eclipse.ui.IEditorReference in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method isLockedAndEdited.
public static boolean isLockedAndEdited(IRepositoryViewObject viewObj) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
ERepositoryStatus status = factory.getStatus(viewObj);
if (status == ERepositoryStatus.LOCK_BY_OTHER) {
return true;
} else if (status == ERepositoryStatus.LOCK_BY_USER) {
IEditorReference openRef = RepositoryResourceUtil.isOpenedInEditor(viewObj);
return openRef != null;
}
return false;
}
Aggregations