Search in sources :

Example 31 with EditingDomain

use of org.eclipse.emf.edit.domain.EditingDomain in project InformationSystem by ObeoNetwork.

the class ViewActionBarContributor 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);
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) IEditingDomainProvider(org.eclipse.emf.edit.domain.IEditingDomainProvider)

Example 32 with EditingDomain

use of org.eclipse.emf.edit.domain.EditingDomain in project InformationSystem by ObeoNetwork.

the class TypesLibraryActionBarContributor 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);
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) IEditingDomainProvider(org.eclipse.emf.edit.domain.IEditingDomainProvider)

Example 33 with EditingDomain

use of org.eclipse.emf.edit.domain.EditingDomain in project InformationSystem by ObeoNetwork.

the class DeleteUserStoriesHandler method execute.

/**
 * {@inheritDoc}
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof UserStoriesView) {
        UserStoriesView view = (UserStoriesView) activePart;
        boolean openConfirm = MessageDialog.openConfirm(view.getSite().getShell(), "Delete User Stories", "Delete the selected user stories ?");
        if (openConfirm == true) {
            EditingDomain editingDomain = view.getEditingDomain();
            if (editingDomain != null) {
                List<UserStory> selectedStories = view.getSelectedStories();
                editingDomain.getCommandStack().execute(DeleteCommand.create(editingDomain, selectedStories));
                view.refresh();
            }
        }
    }
    return null;
}
Also used : UserStoriesView(org.obeonetwork.graal.design.ui.view.UserStoriesView) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) UserStory(org.obeonetwork.graal.UserStory)

Example 34 with EditingDomain

use of org.eclipse.emf.edit.domain.EditingDomain in project InformationSystem by ObeoNetwork.

the class EditUserStoryHandler method execute.

/**
 * {@inheritDoc}
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof UserStoriesView) {
        UserStoriesView view = (UserStoriesView) activePart;
        EditingDomain editingDomain = view.getEditingDomain();
        if (editingDomain != null) {
            UserStory userStory = view.getSelectedStories().get(0);
            UserStoryDialog dialog = new UserStoryDialog(HandlerUtil.getActiveShell(event), userStory);
            int open = dialog.open();
            if (open == Window.OK) {
                CompoundCommand cc = new CompoundCommand();
                cc.append(SetCommand.create(editingDomain, userStory, GraalPackage.eINSTANCE.getNamedElement_Name(), dialog.getName()));
                cc.append(SetCommand.create(editingDomain, userStory, EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description(), dialog.getDescription()));
                editingDomain.getCommandStack().execute(cc);
                view.refresh();
            }
        }
    }
    return null;
}
Also used : UserStoriesView(org.obeonetwork.graal.design.ui.view.UserStoriesView) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) UserStoryDialog(org.obeonetwork.graal.design.ui.dialog.UserStoryDialog) UserStory(org.obeonetwork.graal.UserStory) CompoundCommand(org.eclipse.emf.common.command.CompoundCommand)

Example 35 with EditingDomain

use of org.eclipse.emf.edit.domain.EditingDomain in project InformationSystem by ObeoNetwork.

the class ExtensionUtilitiesActionBarContributor 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);
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) IEditingDomainProvider(org.eclipse.emf.edit.domain.IEditingDomainProvider)

Aggregations

EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)42 IEditingDomainProvider (org.eclipse.emf.edit.domain.IEditingDomainProvider)32 ISelection (org.eclipse.jface.viewers.ISelection)30 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 ExecutionException (org.eclipse.core.commands.ExecutionException)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 EObject (org.eclipse.emf.ecore.EObject)4 DomainPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.DomainPropertiesEditionContext)3 WizardEditingOperation (org.eclipse.emf.eef.runtime.impl.operation.WizardEditingOperation)3 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)3 UserStory (org.obeonetwork.graal.UserStory)3 UserStoriesView (org.obeonetwork.graal.design.ui.view.UserStoriesView)3 IEditorPart (org.eclipse.ui.IEditorPart)2 UserStoryDialog (org.obeonetwork.graal.design.ui.dialog.UserStoryDialog)2 Risk (fr.gouv.mindef.safran.graalextensions.Risk)1 Date (java.util.Date)1 CompoundCommand (org.eclipse.emf.common.command.CompoundCommand)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1