/******************************************************************************* * Copyright (c) 2011 University of Mannheim: Chair for Software Engineering * 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: * Ralph Gerbig - initial API and implementation and initial documentation *******************************************************************************/ package de.uni_mannheim.informatik.swt.models.plm.diagram.custom.menucontributions; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; import de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.ConnectionEditPart; import de.uni_mannheim.informatik.swt.models.plm.diagram.edit.parts.EntityEditPart; /** * * @author Ralph Gerbig (rgerbig@rumms.uni-mannheim.de) * * */ public class DSLAction implements IObjectActionDelegate { public final static String ID = "de.uni_mannheim.informatik.swt.models.plm.diagram.custom.toggledomainconnectionationaction"; private IGraphicalEditPart selectedElement; public DSLAction() { // TODO Auto-generated constructor stub } /** * Reads the rendering information attached to the ontology. If no information * is present it will be created. After reading the information of collapsedDomainConnections * Field it is decided whether the ID of the connection will be removed or added to the * connection. In the end the visual state of the DomainConnectionEditPart is changed. */ @Override public void run(IAction action) { if (selectedElement == null) return; if (selectedElement instanceof EntityEditPart) ((EntityEditPart)selectedElement).updateDSL(); if (selectedElement instanceof ConnectionEditPart) ((ConnectionEditPart)selectedElement).updateView(); } @Override public void selectionChanged(IAction action, ISelection selection) { selectedElement = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.getFirstElement() instanceof EntityEditPart || structuredSelection.getFirstElement() instanceof ConnectionEditPart) { selectedElement = (IGraphicalEditPart) structuredSelection.getFirstElement(); } } } @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { // TODO Auto-generated method stub } }