use of org.eclipse.emf.edit.domain.IEditingDomainProvider in project statecharts by Yakindu.
the class ResourceUnloadingTool method unloadEditorInput.
public static void unloadEditorInput(ResourceSet resourceSet, IEditorInput editorInput) {
final EList<Resource> resources = resourceSet.getResources();
final List<Resource> resourcesToUnload = new ArrayList<Resource>(resources);
IEditorReference[] editorReferences;
try {
editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
} catch (final NullPointerException exc) {
// see bug http://code.google.com/p/gmftools/issues/detail?id=9
return;
}
for (final IEditorReference openEditorReference : editorReferences) {
try {
final IEditorInput openEditorInput = openEditorReference.getEditorInput();
if (openEditorInput != editorInput) {
final IEditorPart openEditor = openEditorReference.getEditor(false);
if (openEditor instanceof IEditingDomainProvider) {
final IEditingDomainProvider openDiagramEditor = (IEditingDomainProvider) openEditor;
final ResourceSet diagramResourceSet = openDiagramEditor.getEditingDomain().getResourceSet();
if (diagramResourceSet == resourceSet) {
final Resource diagramResource = getDiagramResource(diagramResourceSet, openEditorInput);
resourcesToUnload.remove(diagramResource);
final Collection<?> imports = EMFCoreUtil.getImports(diagramResource);
resourcesToUnload.removeAll(imports);
}
}
}
} catch (final Exception exc) {
exc.printStackTrace();
}
}
for (final Resource resourceToUnload : resourcesToUnload) {
try {
resourceToUnload.unload();
resources.remove(resourceToUnload);
} catch (final Throwable t) {
t.printStackTrace();
}
}
}
use of org.eclipse.emf.edit.domain.IEditingDomainProvider in project metalib by softlang.
the class FsmlActionBarContributor method selectionChanged.
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void selectionChanged(SelectionChangedEvent event) {
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
Object object = ((IStructuredSelection) selection).getFirstElement();
EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors, selection);
createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions, null);
createSiblingMenuManager.update(true);
}
}
use of org.eclipse.emf.edit.domain.IEditingDomainProvider in project statecharts by Yakindu.
the class StatechartDiagramGlobalActionHandler method getEditingDomain.
/**
* Copied from
* DiagramGlobalActionHandler.getEditingDomain(IDiagramWorkbenchPart) because it is private.
*/
private TransactionalEditingDomain getEditingDomain(IDiagramWorkbenchPart part) {
TransactionalEditingDomain result = null;
IEditingDomainProvider provider = (IEditingDomainProvider) part.getAdapter(IEditingDomainProvider.class);
if (provider != null) {
EditingDomain domain = provider.getEditingDomain();
if (domain != null && domain instanceof TransactionalEditingDomain) {
result = (TransactionalEditingDomain) domain;
}
}
return result;
}
use of org.eclipse.emf.edit.domain.IEditingDomainProvider in project InformationSystem by ObeoNetwork.
the class StateMachineActionBarContributor method selectionChanged.
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void selectionChanged(SelectionChangedEvent event) {
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
Object object = ((IStructuredSelection) selection).getFirstElement();
EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors, selection);
createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions, null);
createSiblingMenuManager.update(true);
}
}
use of org.eclipse.emf.edit.domain.IEditingDomainProvider in project InformationSystem by ObeoNetwork.
the class SoaActionBarContributor method selectionChanged.
/**
* This implements
* {@link org.eclipse.jface.viewers.ISelectionChangedListener}, handling
* {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for
* the children and siblings that can be added to the selected object and
* updating the menus accordingly. <!-- begin-user-doc --> <!-- end-user-doc
* -->
*
* @generated
*/
public void selectionChanged(SelectionChangedEvent event) {
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
Object object = ((IStructuredSelection) selection).getFirstElement();
EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors, selection);
createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions, null);
createSiblingMenuManager.update(true);
}
}
Aggregations