blob: ae55d6c231c955a424fa2a6de1ed555af5017478 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2019 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:
* Xavier Le Pallec (for CEA LIST) xlepallec@lilo.org - Bug 558456
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.clazz.lf.autosizeableclasses.edit.policies;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.papyrus.uml.diagram.clazz.lf.autosizeableclasses.preference.Settings;
/**
* This is an edit policy that inherits from
* {@link org.eclipse.papyrus.uml.diagram.clazz.lf.autosizeableclasses.edit.policies.HoveringElementEditPolicy}
* and dedicated to process request / hovering events for elements of an uml
* class that can potentially be collapsed or expanded.
*
*/
public class HideableClassElementEditPolicy extends HoveringElementEditPolicy {
/**
* see
* {@link org.eclipse.papyrus.uml.diagram.clazz.lf.autosizeableclasses.edit.policies.HoveringElementEditPolicy#PolicyToInheritFrom(EditPart)}
*
* @param editPart edit part which the edit policy is associated to
*/
public HideableClassElementEditPolicy(EditPart editPart) {
super(editPart);
}
/**
* see
* {@link org.eclipse.papyrus.uml.diagram.clazz.lf.autosizeableclasses.edit.policies.HoveringElementEditPolicy}
* for global explanation of edit policy and this method. Short summary:
* intercept a move (during a creation/drop interaction) over the associated
* graphical element
*
* @param request the request corresponding to the interaction event
*/
@Override
public Command getCommand(Request request) {
if (Settings.getInstance().isActivated() && isCreationOrDropRequest(request)) {
setCurrentRequest(request);
getStateMachine().getLowEventManager().hoveringAClass(editPart);
}
return super.getCommand(request);
}
}