blob: ff324163c352723be6a11b8ec61d6e535316122b [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2013, 2017 CEA LIST.
*
* 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:
* CEA LIST - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.decorators;
import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
import org.eclipse.emf.cdo.dawn.appearance.IDawnElementStylizerFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
/**
* This is the PapyrusElementStylizerFactory type. Enjoy.
*/
public class PapyrusElementStylizerFactory
implements IDawnElementStylizerFactory {
public PapyrusElementStylizerFactory() {
super();
}
@Override
public DawnElementStylizer getElementStylizer(Object object) {
DawnElementStylizer result = null;
if (isPapyrusEditPart(object)) {
if (object instanceof ConnectionEditPart) {
result = new PapyrusConnectionEditPartStylizer();
} else {
result = new PapyrusNodeEditPartStylizer();
}
} else if (object instanceof EObject) {
result = new PapyrusElementStylizer();
}
return result;
}
protected boolean isPapyrusEditPart(Object object) {
boolean result = object instanceof IPapyrusEditPart;
if (!result && (object instanceof EditPart)) {
EditPart editPart = ((EditPart) object).getRoot().getContents();
Object model = editPart.getModel();
if (model instanceof EObject) {
result = CDOUtils.getResourceSet((EObject) model) instanceof ModelSet;
}
}
return result;
}
}