use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.
the class InteractionServices method changeParentForInteraction.
/**
* Change the parent of an interaction with a selected one
* @param interaction
* @return
*/
public Interaction changeParentForInteraction(final Interaction interaction) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
InteractionParentSelectionLabelProvider labelProvider = new InteractionParentSelectionLabelProvider(adapterFactory);
InteractionParentSelectionContentProvider contentProvider = new InteractionParentSelectionContentProvider(adapterFactory);
ElementTreeSelectionDialog dlg = new ElementTreeSelectionDialog(shell, labelProvider, contentProvider);
dlg.setHelpAvailable(false);
dlg.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
Object selectedObject = selection[0];
if (selectedObject instanceof EObject) {
IPermissionAuthority authority = PermissionAuthorityRegistry.getDefault().getPermissionAuthority((EObject) selectedObject);
if (authority != null) {
LockStatus lockStatus = authority.getLockStatus((EObject) selectedObject);
if (LockStatus.LOCKED_BY_OTHER.equals(lockStatus)) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "This element is locked by another user");
}
}
}
return new Status(IStatus.OK, Activator.PLUGIN_ID, "");
}
});
dlg.setTitle("Change interaction's parent");
dlg.setMessage("Select the new parent for the interaction");
Session session = SessionManager.INSTANCE.getSession(interaction);
if (session == null) {
return interaction;
}
dlg.setInput(session.getSemanticResources().toArray());
dlg.setInitialSelection(interaction.eContainer());
int btn = dlg.open();
if (btn == Dialog.OK) {
Object selectedElement = dlg.getFirstResult();
if (selectedElement instanceof ObeoDSMObject && selectedElement != interaction.eContainer()) {
// Change the parent
((ObeoDSMObject) selectedElement).getBehaviours().add(interaction);
}
}
return interaction;
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.
the class UtilServices method getLabel.
public String getLabel(EObject object) {
ComposedAdapterFactory composeable = new ComposedAdapterFactory();
composeable.addAdapterFactory(dbEvolution);
composeable.addAdapterFactory(compare);
composeable.addAdapterFactory(database);
composeable.addAdapterFactory(library);
IItemLabelProvider provider = (IItemLabelProvider) composeable.adapt(object, IItemLabelProvider.class);
if (provider != null) {
return provider.getText(object);
}
return "";
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project InformationSystem by ObeoNetwork.
the class EnvironmentEditor method initializeEditingDomain.
/**
* This sets up the editing domain for the model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new EnvironmentItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new TechnicalIDItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
//
commandStack.addCommandStackListener(new CommandStackListener() {
public void commandStackChanged(final EventObject event) {
getContainer().getDisplay().asyncExec(new Runnable() {
public void run() {
firePropertyChange(IEditorPart.PROP_DIRTY);
// Try to select the affected objects.
//
Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
if (mostRecentCommand != null) {
setSelectionToViewer(mostRecentCommand.getAffectedObjects());
}
for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
PropertySheetPage propertySheetPage = i.next();
if (propertySheetPage.getControl().isDisposed()) {
i.remove();
} else {
propertySheetPage.refresh();
}
}
}
});
}
});
// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project gemoc-studio by eclipse.
the class FsmEditor method initializeEditingDomain.
/**
* This sets up the editing domain for the model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new FsmItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
//
commandStack.addCommandStackListener(new CommandStackListener() {
public void commandStackChanged(final EventObject event) {
getContainer().getDisplay().asyncExec(new Runnable() {
public void run() {
firePropertyChange(IEditorPart.PROP_DIRTY);
// Try to select the affected objects.
//
Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
if (mostRecentCommand != null) {
setSelectionToViewer(mostRecentCommand.getAffectedObjects());
}
for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
PropertySheetPage propertySheetPage = i.next();
if (propertySheetPage.getControl().isDisposed()) {
i.remove();
} else {
propertySheetPage.refresh();
}
}
}
});
}
});
// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
use of org.eclipse.emf.edit.provider.ComposedAdapterFactory in project Malai by arnobl.
the class WidgetEditor method initializeEditingDomain.
/**
* This sets up the editing domain for the model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void initializeEditingDomain() {
// Create an adapter factory that yields item providers.
//
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new WidgetItemProviderAdapterFactory());
adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
// Create the command stack that will notify this editor as commands are executed.
//
BasicCommandStack commandStack = new BasicCommandStack();
// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
//
commandStack.addCommandStackListener(new CommandStackListener() {
public void commandStackChanged(final EventObject event) {
getContainer().getDisplay().asyncExec(new Runnable() {
public void run() {
firePropertyChange(IEditorPart.PROP_DIRTY);
// Try to select the affected objects.
//
Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
if (mostRecentCommand != null) {
setSelectionToViewer(mostRecentCommand.getAffectedObjects());
}
if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
propertySheetPage.refresh();
}
}
});
}
});
// Create the editing domain with a special command stack.
//
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
Aggregations