| /***************************************************************************** |
| * Copyright (c) 2019 CEA LIST, and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation |
| * |
| *****************************************************************************/ |
| package org.eclipse.papyrus.sysml16.diagram.blockdefinition.internal.factory; |
| |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; |
| import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; |
| import org.eclipse.gmf.runtime.notation.Location; |
| import org.eclipse.gmf.runtime.notation.Node; |
| import org.eclipse.gmf.runtime.notation.NotationFactory; |
| import org.eclipse.gmf.runtime.notation.Shape; |
| import org.eclipse.gmf.runtime.notation.View; |
| import org.eclipse.jface.preference.IPreferenceStore; |
| import org.eclipse.papyrus.sysml16.diagram.common.internal.factory.AbstractBasicViewFactory; |
| import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassAttributeCompartmentEditPart; |
| import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassFloatingNameEditPart; |
| import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNameEditPart; |
| import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassNestedClassifierCompartmentEditPart; |
| import org.eclipse.papyrus.uml.diagram.clazz.edit.parts.ClassOperationCompartmentEditPart; |
| import org.eclipse.papyrus.uml.diagram.clazz.part.UMLVisualIDRegistry; |
| import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; |
| |
| /** |
| * |
| * extraction from classdiagram UML view Provider |
| * |
| */ |
| public class BlockClassifierViewFactory extends AbstractBasicViewFactory { |
| |
| /** |
| * Base element of Block |
| */ |
| private static final String CLASS = "Class";//$NON-NLS-1$ |
| |
| @Override |
| public Node createElementView(EObject domainElement, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { |
| Shape node = NotationFactory.eINSTANCE.createShape(); |
| node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); |
| node.setType(semanticHint); |
| ViewUtil.insertChildView(containerView, node, index, persisted); |
| node.setElement(domainElement); |
| stampShortcut(containerView, node); |
| // initializeFromPreferences |
| final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); |
| |
| PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, CLASS); |
| createLabel(node, UMLVisualIDRegistry.getType(ClassNameEditPart.VISUAL_ID)); |
| Node label8510 = createLabel(node, UMLVisualIDRegistry.getType(ClassFloatingNameEditPart.VISUAL_ID)); |
| label8510.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); |
| Location location8510 = (Location) label8510.getLayoutConstraint(); |
| location8510.setX(0); |
| location8510.setY(5); |
| createCompartment(node, UMLVisualIDRegistry.getType(ClassAttributeCompartmentEditPart.VISUAL_ID), true, true, true, true); |
| createCompartment(node, UMLVisualIDRegistry.getType(ClassOperationCompartmentEditPart.VISUAL_ID), true, true, true, true); |
| createCompartment(node, UMLVisualIDRegistry.getType(ClassNestedClassifierCompartmentEditPart.VISUAL_ID), true, true, true, true); |
| PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, CLASS); |
| return node; |
| } |
| } |