View | Details | Raw Unified | Return to bug 152706 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/common/ui/action/AbstractActionHandler.java (-23 / +17 lines)
Lines 40-45 Link Here
40
import org.eclipse.swt.widgets.Event;
40
import org.eclipse.swt.widgets.Event;
41
import org.eclipse.ui.IPartListener;
41
import org.eclipse.ui.IPartListener;
42
import org.eclipse.ui.IPropertyListener;
42
import org.eclipse.ui.IPropertyListener;
43
import org.eclipse.ui.ISelectionService;
43
import org.eclipse.ui.IWorkbenchPage;
44
import org.eclipse.ui.IWorkbenchPage;
44
import org.eclipse.ui.IWorkbenchPart;
45
import org.eclipse.ui.IWorkbenchPart;
45
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.PlatformUI;
Lines 409-425 Link Here
409
	 * @return The current selection.
410
	 * @return The current selection.
410
	 */
411
	 */
411
	protected ISelection getSelection() {
412
	protected ISelection getSelection() {
412
		ISelection selection = null;
413
        ISelection selection = null;
413
		ISelectionProvider selectionProvider = getWorkbenchPart().getSite()
414
        ISelectionService selectionService = null;
414
			.getSelectionProvider();
415
        if (getWorkbenchPart() != null && getWorkbenchPart().getSite().getWorkbenchWindow() != null) {
416
            selectionService = getWorkbenchPart().getSite()
417
                .getWorkbenchWindow().getSelectionService();
418
        }
415
419
416
		if (selectionProvider != null) {
420
        if (selectionService != null) {
417
			selection = selectionProvider.getSelection();
421
            selection = selectionService.getSelection();
418
		}
422
        }
419
423
420
		return (selection != null) ? selection
424
        return (selection != null) ? selection
421
			: StructuredSelection.EMPTY;
425
            : StructuredSelection.EMPTY;
422
	}
426
    }
423
427
424
	/**
428
	/**
425
	 * Retrieves the current structured selection.
429
	 * Retrieves the current structured selection.
Lines 427-446 Link Here
427
	 * @return The current structured selection.
431
	 * @return The current structured selection.
428
	 */
432
	 */
429
	protected IStructuredSelection getStructuredSelection() {
433
	protected IStructuredSelection getStructuredSelection() {
430
		IStructuredSelection selection = null;
434
        ISelection selection = getSelection();
431
		ISelectionProvider selectionProvider = null;
435
        return (selection instanceof StructuredSelection) ? (StructuredSelection) selection
432
		if (getWorkbenchPart() != null) {
436
            : StructuredSelection.EMPTY;
433
			selectionProvider = getWorkbenchPart().getSite()
437
    }
434
				.getSelectionProvider();
435
		}
436
437
		if (selectionProvider != null
438
			&& selectionProvider.getSelection() instanceof IStructuredSelection) {
439
			selection = (IStructuredSelection) selectionProvider.getSelection();
440
		}
441
		return (selection != null) ? selection
442
			: StructuredSelection.EMPTY;
443
	}
444
438
445
	/**
439
	/**
446
	 * Retrieves a Boolean indicating whether this action handler can be run.
440
	 * Retrieves a Boolean indicating whether this action handler can be run.
(-)src/org/eclipse/gmf/runtime/diagram/ui/internal/actions/DeleteFromModelAction.java (-3 / +10 lines)
Lines 22-29 Link Here
22
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
22
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
23
import org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDeleteFromAction;
23
import org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDeleteFromAction;
24
import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
24
import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
25
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
26
import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
25
import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
26
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
27
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
27
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
28
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
28
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
29
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
29
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
Lines 82-90 Link Here
82
			if (editPart instanceof IGraphicalEditPart) {
82
			if (editPart instanceof IGraphicalEditPart) {
83
				IGraphicalEditPart gEditPart = (IGraphicalEditPart) editPart;
83
				IGraphicalEditPart gEditPart = (IGraphicalEditPart) editPart;
84
				View view = (View) gEditPart.getModel();
84
				View view = (View) gEditPart.getModel();
85
				// Disallow diagram deletion from model only if it is the top most diagram
86
				EObject container = view.eContainer();
85
				EObject element = ViewUtil.resolveSemanticElement(view);
87
				EObject element = ViewUtil.resolveSemanticElement(view);
86
				if ((element == null) || (element.eIsProxy())
88
				if ((element == null) || (element.eIsProxy())
87
					|| (element instanceof Diagram)) {
89
						|| (element instanceof Diagram)
90
						|| (view instanceof Diagram && (container == null || !(container instanceof View)))) {
88
					return false;
91
					return false;
89
				}
92
				}
90
			} else {
93
			} else {
Lines 133-141 Link Here
133
				IGraphicalEditPart gEditPart = 
136
				IGraphicalEditPart gEditPart = 
134
					(IGraphicalEditPart) editPart;
137
					(IGraphicalEditPart) editPart;
135
				View view = (View)gEditPart.getModel();
138
				View view = (View)gEditPart.getModel();
139
				// Don't delete diagram from model only if it is the top most diagram
140
				EObject container = view.eContainer();
136
				EObject element = ViewUtil.resolveSemanticElement(view);
141
				EObject element = ViewUtil.resolveSemanticElement(view);
137
				if(element instanceof Diagram)
142
				if ((element instanceof Diagram)
143
						|| (view instanceof Diagram && (container == null || !(container instanceof View)))) {
138
					return null;
144
					return null;
145
				}
139
			}
146
			}
140
			Command curCommand = editPart.getCommand(request);
147
			Command curCommand = editPart.getCommand(request);
141
			if (curCommand != null) {
148
			if (curCommand != null) {
(-)src/org/eclipse/gmf/runtime/diagram/ui/editparts/TreeEditPart.java (-9 lines)
Lines 18-24 Link Here
18
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
18
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
19
import org.eclipse.emf.transaction.TransactionalEditingDomain;
19
import org.eclipse.emf.transaction.TransactionalEditingDomain;
20
import org.eclipse.emf.transaction.util.TransactionUtil;
20
import org.eclipse.emf.transaction.util.TransactionUtil;
21
import org.eclipse.gef.EditPolicy;
22
import org.eclipse.gef.editparts.AbstractTreeEditPart;
21
import org.eclipse.gef.editparts.AbstractTreeEditPart;
23
import org.eclipse.gmf.runtime.common.ui.services.action.filter.ActionFilterService;
22
import org.eclipse.gmf.runtime.common.ui.services.action.filter.ActionFilterService;
24
import org.eclipse.gmf.runtime.common.ui.services.icon.IconOptions;
23
import org.eclipse.gmf.runtime.common.ui.services.icon.IconOptions;
Lines 29-35 Link Here
29
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
28
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker;
30
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
29
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
31
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
30
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
32
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy;
33
import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
31
import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
34
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
32
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
35
import org.eclipse.gmf.runtime.notation.NotationPackage;
33
import org.eclipse.gmf.runtime.notation.NotationPackage;
Lines 104-116 Link Here
104
        super.deactivate();
102
        super.deactivate();
105
    }
103
    }
106
104
107
    /**
108
     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
109
     */
110
    protected void createEditPolicies() {
111
        installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy());
112
    }
113
114
    /** gets the model as a <code>View</code>
105
    /** gets the model as a <code>View</code>
115
     * @return View
106
     * @return View
116
     */
107
     */

Return to bug 152706