| //------------------------------------------------------------------------------ |
| // Copyright (c) 2005, 2006 IBM Corporation and others. |
| // 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: |
| // IBM Corporation - initial implementation |
| //------------------------------------------------------------------------------ |
| package org.eclipse.epf.authoring.gef.edit.policies; |
| |
| import org.eclipse.epf.authoring.gef.figures.SelectableLabel; |
| import org.eclipse.gef.GraphicalEditPart; |
| import org.eclipse.gef.editpolicies.NonResizableEditPolicy; |
| |
| /** |
| * Handles selection of activites. Primary selection is denoted by highlight and |
| * a focus rectangle. Normal selection is denoted by highlight only. |
| * |
| * @author Phong Nguyen Le |
| * @since 1.0 |
| */ |
| public class LabelSelectionEditPolicy extends NonResizableEditPolicy { |
| |
| private SelectableLabel getLabel() { |
| GraphicalEditPart part = (GraphicalEditPart) getHost(); |
| return ((SelectableLabel) part.getFigure()); |
| } |
| |
| /** |
| * @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#hideFocus() |
| */ |
| protected void hideFocus() { |
| getLabel().setFocus(false); |
| } |
| |
| /** |
| * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#hideSelection() |
| */ |
| protected void hideSelection() { |
| getLabel().setSelected(false); |
| getLabel().setFocus(false); |
| |
| } |
| |
| /** |
| * @see org.eclipse.gef.editpolicies.NonResizableEditPolicy#showFocus() |
| */ |
| protected void showFocus() { |
| getLabel().setFocus(true); |
| } |
| |
| /** |
| * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection() |
| */ |
| protected void showPrimarySelection() { |
| getLabel().setSelected(true); |
| getLabel().setFocus(true); |
| } |
| |
| /** |
| * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection() |
| */ |
| protected void showSelection() { |
| getLabel().setSelected(true); |
| getLabel().setFocus(false); |
| } |
| |
| } |