use of org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput in project tdq-studio-se by Talend.
the class WorkbenchUtils method closeAndOpenEditor.
/**
* close and open the editors same method {@link CorePlugin}.getDefault().itemIsOpening() MOD TDQ-8360 20140410
* yyin: will only operate the analysis who is related and has opened (by its observer --added when opening)
*
* @param iEditorReference
*/
private static void closeAndOpenEditor(List<IEditorReference> iEditorReference) {
// Refresh current opened editors.
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkbenchPartReference activePartReference = activePage.getActivePartReference();
// MOD qiongli 2011-9-8 TDQ-3317.when focucs on DI perspective,don't refresh the open editors
DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
if (findView == null) {
return;
}
if (iEditorReference.size() > 0) {
try {
for (IEditorReference editorRef : iEditorReference) {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput instanceof AbstractItemEditorInput) {
AbstractItemEditorInput anaItemEditorInput = (AbstractItemEditorInput) editorInput;
// close the editor
activePage.closeEditor(editorRef.getEditor(false), false);
// reopen the analysis
new OpenItemEditorAction(new IRepositoryNode[] { anaItemEditorInput.getRepNode() }).run();
}
}
} catch (PartInitException e) {
log.error(e);
}
}
activePage.activate(activePartReference.getPart(false));
}
use of org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput in project tdq-studio-se by Talend.
the class CorePlugin method itemIsOpening.
/**
* check the item's editor is opening or not.
*
* @param item
* @param closeEditor close the editor if it is opening
* @return
*/
public boolean itemIsOpening(Item item, boolean closeEditor) {
boolean opening = false;
IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
IEditorInput editorInput = null;
Property property = item.getProperty();
for (IEditorReference reference : editorReferences) {
try {
editorInput = reference.getEditorInput();
if (editorInput instanceof FileEditorInput) {
FileEditorInput fileInput = (FileEditorInput) editorInput;
if (property.eResource() != null) {
IPath itemPath = PropertyHelper.getItemPath(property);
if (itemPath != null && itemPath.equals(fileInput.getFile().getFullPath())) {
opening = true;
if (closeEditor) {
activePage.closeEditor(reference.getEditor(false), false);
}
break;
}
}
} else if (editorInput instanceof AbstractItemEditorInput) {
AbstractItemEditorInput input = (AbstractItemEditorInput) editorInput;
Item it = input.getItem();
if (it != null && property != null && it.getProperty().getId().equals(property.getId())) {
opening = true;
if (closeEditor) {
activePage.closeEditor(reference.getEditor(false), false);
}
break;
}
}
} catch (PartInitException e) {
log.error(e);
continue;
}
}
return opening;
}
use of org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput in project tdq-studio-se by Talend.
the class CorePlugin method refreshOpenedEditor.
/**
* refresh the related connection which is opened in DQ side.
*
* @param item
*/
public void refreshOpenedEditor(Item item) {
if (item == null) {
return;
}
IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
Property property = item.getProperty();
for (IEditorReference reference : editorReferences) {
try {
IEditorInput input = reference.getEditorInput();
if (input instanceof AbstractItemEditorInput) {
AbstractItemEditorInput itemInput = (AbstractItemEditorInput) input;
Item it = itemInput.getItem();
if (it != null && property != null && it.getProperty().getId().equals(property.getId())) {
// make sure the item in editorInput is latest.
if (!item.equals(it)) {
itemInput.setRepNode(RepositoryNodeHelper.recursiveFind(property));
}
CommonFormEditor editor = (CommonFormEditor) reference.getEditor(false);
editor.refreshEditor();
break;
}
}
} catch (PartInitException e) {
log.error(e);
continue;
}
}
}
use of org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput in project tdq-studio-se by Talend.
the class WorkbenchUtils method getIEditorReference.
/**
* Get Editors which is is same as editorID --used for the analysis editor only
*
* @param editorID
* @param analysisName
* @return
*/
private static List<IEditorReference> getIEditorReference(String editorID, String analysisName) {
List<IEditorReference> returnCode = new ArrayList<IEditorReference>();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editors = activePage.getEditorReferences();
if (editors != null) {
for (IEditorReference editorRef : editors) {
if (editorRef.getId().equals(editorID)) {
IEditorInput editorInput;
try {
editorInput = editorRef.getEditorInput();
if (editorInput instanceof AbstractItemEditorInput) {
AnalysisItemEditorInput anaItemEditorInput = (AnalysisItemEditorInput) editorInput;
// if not pointed which analysis, add all opened ones.
if (StringUtils.isEmpty(analysisName) || StringUtils.equals(analysisName, anaItemEditorInput.getModel().getName())) {
returnCode.add(editorRef);
}
}
} catch (PartInitException e) {
log.error(e, e);
}
}
}
}
return returnCode;
}
use of org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput in project tdq-studio-se by Talend.
the class RepNodeUtils method closeModelElementEditor.
/**
* close ModelElement node's editor.
*
* @param nodes
*/
public static void closeModelElementEditor(List<? extends IRepositoryNode> nodes, boolean save) {
List<String> uuids = RepositoryNodeHelper.getUuids(nodes);
List<IEditorReference> need2CloseEditorRefs = new ArrayList<IEditorReference>();
IEditorReference[] editorReferences = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
try {
for (IEditorReference editorRef : editorReferences) {
if (editorRef != null) {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput != null) {
if (editorInput instanceof AbstractItemEditorInput) {
String modelElementUuid = ((AbstractItemEditorInput) editorInput).getModelElementUuid();
if (modelElementUuid != null && uuids.contains(modelElementUuid)) {
need2CloseEditorRefs.add(editorRef);
}
}
}
}
}
} catch (PartInitException e) {
log.warn(e, e);
}
if (need2CloseEditorRefs.size() > 0) {
CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditors(need2CloseEditorRefs.toArray(new IEditorReference[need2CloseEditorRefs.size()]), save);
}
}
Aggregations