Skip to content
Snippets Groups Projects
Commit bad5c021 authored by Chen Wenwen's avatar Chen Wenwen
Browse files

refs 1072
parent 9634c8b7
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: CFD88AAA5841CB3544A2499BEAC01733
* @ConQAT.Rating YELLOW Hash: 62C3F0ECA931171A7FCCE384F7FA3131
*/
public class ModelEditorBindingService extends
EObjectAwareServiceBase<IModelEditorBinding<EObject>> implements
......@@ -165,12 +165,27 @@ public class ModelEditorBindingService extends
/** {@inheritDoc} */
@Override
public void closeEditors(EObject parentElement) {
for(IEditorPart editor : currentEditors.keySet()) {
IEditorPart[] parts = new IEditorPart[0];
for(IEditorPart editor : currentEditors.keySet().toArray(parts)) {
EObject editedElement = currentEditors.get(editor);
if(KernelModelElementUtils.isChildElementOf(editedElement, parentElement)) {
closeEditor(editor);
}
}
}
/** {@inheritDoc} */
@Override
public void closeEditor(EObject element) {
IEditorPart[] parts = new IEditorPart[0];
for(IEditorPart editor : currentEditors.keySet().toArray(parts)) {
EObject editedElement = currentEditors.get(editor);
if(editedElement.equals(element)) {
closeEditor(editor);
}
}
}
/** Closes the given editor. */
......@@ -181,6 +196,7 @@ public class ModelEditorBindingService extends
editor.getSite().getPage().closeEditor(editor, false);
}
});
currentEditors.remove(editor);
}
/** {@inheritDoc} */
......@@ -203,6 +219,7 @@ public class ModelEditorBindingService extends
ITopLevelElement top = currentCommandStacks.get(eo);
currentCommandStacks.remove(eo);
currentEditors.remove(part);
// clean up command stack registration
for(IEditorPart other : currentEditors.keySet()) {
if(top == currentCommandStacks.get(currentEditors.get(other))) {
......@@ -258,4 +275,11 @@ public class ModelEditorBindingService extends
}
return null;
}
/** {@inheritDoc} */
@Override
public boolean isOpen(EObject element) {
return currentEditors.containsValue(element);
}
}
......@@ -33,7 +33,7 @@ import org.fortiss.tooling.kernel.ui.internal.ModelEditorBindingService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 1BD1646F7084B0FDF5CC9E6A225C03CA
* @ConQAT.Rating YELLOW Hash: 655524C280C4FB1C627803B821E087B8
*/
public interface IModelEditorBindingService {
......@@ -46,6 +46,12 @@ public interface IModelEditorBindingService {
/** Closes editors which depend on the given element or a sub-element. */
void closeEditors(EObject parentElement);
/** Closes editor of the given element. */
void closeEditor(EObject element);
/** Check whether editor of the given element is opened. */
boolean isOpen(EObject element);
/** Returns the currently active editor. */
IModelEditor<EObject> getActiveEditor();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment