diff options
Diffstat (limited to 'plugins/org.eclipse.sirius.diagram/specific/org/eclipse/sirius/diagram/tools/internal/providers/decorators/EditModeDecoratorProvider.java')
-rw-r--r-- | plugins/org.eclipse.sirius.diagram/specific/org/eclipse/sirius/diagram/tools/internal/providers/decorators/EditModeDecoratorProvider.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/specific/org/eclipse/sirius/diagram/tools/internal/providers/decorators/EditModeDecoratorProvider.java b/plugins/org.eclipse.sirius.diagram/specific/org/eclipse/sirius/diagram/tools/internal/providers/decorators/EditModeDecoratorProvider.java new file mode 100644 index 0000000000..fcb569eab2 --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram/specific/org/eclipse/sirius/diagram/tools/internal/providers/decorators/EditModeDecoratorProvider.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2009, 2009 THALES GLOBAL SERVICES. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.tools.internal.providers.decorators; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.CreateDecoratorsOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider; +import org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget; + +import org.eclipse.sirius.diagram.edit.api.part.IDiagramElementEditPart; + +/** + * This decorator is installed on SiriusElements edit parts. It display an + * icon when the element is in disableEditMode (and another where it is also + * invalid). + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + * + */ +public class EditModeDecoratorProvider extends AbstractProvider implements IDecoratorProvider { + + /** + * KEY for descriptors map. + */ + public static final String KEY = "editModeDecorator"; + + /** + * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.common.core.service.IProvider#provides(org.eclipse.gmf.runtime.common.core.service.IOperation) + */ + public boolean provides(final IOperation operation) { + if (!(operation instanceof CreateDecoratorsOperation)) { + return false; + } + boolean provide = false; + final IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget(); + final EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); + if (editPart instanceof IDiagramElementEditPart) { + provide = true; + } + return provide; + } + + /** + * + * {@inheritDoc} + * + * @see org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorProvider#createDecorators(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecoratorTarget) + */ + public void createDecorators(final IDecoratorTarget decoratorTarget) { + final EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); + if (editPart instanceof IDiagramElementEditPart) { + decoratorTarget.installDecorator(KEY, new EditModeDecorator(decoratorTarget)); + } + } +} |