kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2001, 2006 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
kchong | 2be71b3 | 2006-04-11 16:32:03 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.xsd.ui.internal.adt.design.editparts; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 12 | |
csalter | f42b52e | 2006-05-11 05:20:57 +0000 | [diff] [blame] | 13 | import java.util.Iterator; |
| 14 | import java.util.List; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 15 | import org.eclipse.draw2d.ColorConstants; |
| 16 | import org.eclipse.draw2d.IFigure; |
| 17 | import org.eclipse.draw2d.Label; |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 18 | import org.eclipse.draw2d.PositionConstants; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 19 | import org.eclipse.draw2d.geometry.Point; |
| 20 | import org.eclipse.gef.DragTracker; |
| 21 | import org.eclipse.gef.EditPart; |
| 22 | import org.eclipse.gef.EditPolicy; |
| 23 | import org.eclipse.gef.GraphicalEditPart; |
| 24 | import org.eclipse.gef.LayerConstants; |
| 25 | import org.eclipse.gef.Request; |
| 26 | import org.eclipse.gef.RequestConstants; |
| 27 | import org.eclipse.gef.commands.Command; |
| 28 | import org.eclipse.gef.editparts.AbstractGraphicalEditPart; |
| 29 | import org.eclipse.gef.requests.DirectEditRequest; |
| 30 | import org.eclipse.gef.requests.LocationRequest; |
kchong | 43dd1cc | 2006-07-24 16:48:58 +0000 | [diff] [blame] | 31 | import org.eclipse.swt.custom.CCombo; |
kchong | f9510bf | 2006-09-05 21:28:47 +0000 | [diff] [blame] | 32 | import org.eclipse.swt.widgets.Display; |
kchong | bd37beb | 2006-05-13 18:38:38 +0000 | [diff] [blame] | 33 | import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; |
kchong | 2be71b3 | 2006-04-11 16:32:03 +0000 | [diff] [blame] | 34 | import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ComboBoxCellEditorManager; |
| 35 | import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.ElementReferenceDirectEditManager; |
| 36 | import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator; |
| 37 | import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager; |
| 38 | import org.eclipse.wst.xsd.ui.internal.adt.design.directedit.TypeReferenceDirectEditManager; |
| 39 | import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.FocusTypeColumn; |
| 40 | import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTDirectEditPolicy; |
| 41 | import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.ADTSelectionFeedbackEditPolicy; |
| 42 | import org.eclipse.wst.xsd.ui.internal.adt.design.editpolicies.IADTUpdateCommand; |
| 43 | import org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure; |
kchong | 83beb0b | 2006-04-12 21:55:41 +0000 | [diff] [blame] | 44 | import org.eclipse.wst.xsd.ui.internal.adt.editor.Messages; |
kchong | 1410efb | 2006-04-27 18:48:05 +0000 | [diff] [blame] | 45 | import org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject; |
kchong | 2be71b3 | 2006-04-11 16:32:03 +0000 | [diff] [blame] | 46 | import org.eclipse.wst.xsd.ui.internal.adt.facade.IField; |
| 47 | import org.eclipse.wst.xsd.ui.internal.adt.facade.IType; |
| 48 | import org.eclipse.wst.xsd.ui.internal.design.editpolicies.GraphNodeDragTracker; |
kchong | bd37beb | 2006-05-13 18:38:38 +0000 | [diff] [blame] | 49 | import org.eclipse.xsd.XSDNamedComponent; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 50 | |
| 51 | public class BaseFieldEditPart extends BaseTypeConnectingEditPart implements INamedEditPart |
| 52 | { |
| 53 | protected TypeReferenceConnection connectionFigure; |
| 54 | protected ADTDirectEditPolicy adtDirectEditPolicy = new ADTDirectEditPolicy(); |
kchong | 42cdb08 | 2006-04-11 21:11:59 +0000 | [diff] [blame] | 55 | protected TypeUpdateCommand typeUpdateCommand = new TypeUpdateCommand(); |
| 56 | protected ElementReferenceUpdateCommand elementUpdateCommand = new ElementReferenceUpdateCommand(); |
| 57 | protected TypeReferenceConnection connectionFeedbackFigure; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 58 | |
| 59 | protected IFigure createFigure() |
| 60 | { |
| 61 | IFieldFigure figure = getFigureFactory().createFieldFigure(getModel()); |
| 62 | figure.setForegroundColor(ColorConstants.black); |
| 63 | return figure; |
| 64 | } |
| 65 | |
| 66 | public IFieldFigure getFieldFigure() |
| 67 | { |
| 68 | return (IFieldFigure)figure; |
| 69 | } |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 70 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 71 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 72 | protected boolean shouldDrawConnection() |
| 73 | { |
| 74 | boolean result = false; |
| 75 | |
| 76 | // For now we only want to produce outbound lines from a Field to a Type |
| 77 | // when the field in contained in the 'focus' edit part |
| 78 | for (EditPart parent = getParent(); parent != null; parent = parent.getParent()) |
| 79 | { |
| 80 | if (parent.getModel() instanceof FocusTypeColumn) |
| 81 | { |
| 82 | result = true; |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | return result; |
| 87 | } |
| 88 | |
csalter | f42b52e | 2006-05-11 05:20:57 +0000 | [diff] [blame] | 89 | private EditPart getTargetEditPart(IType type) |
| 90 | { |
| 91 | ColumnEditPart columnEditPart = null; |
| 92 | for (EditPart editPart = this; editPart != null; editPart = editPart.getParent()) |
| 93 | { |
| 94 | if (editPart instanceof ColumnEditPart) |
| 95 | { |
| 96 | columnEditPart = (ColumnEditPart)editPart; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | if (columnEditPart != null) |
| 101 | { |
| 102 | // get the next column |
| 103 | EditPart parent = columnEditPart.getParent(); |
| 104 | List columns = parent.getChildren(); |
| 105 | int index = columns.indexOf(columnEditPart); |
csalter | 92b38ec | 2006-07-24 17:23:45 +0000 | [diff] [blame] | 106 | if (index + 1 < columns.size()) |
csalter | f42b52e | 2006-05-11 05:20:57 +0000 | [diff] [blame] | 107 | { |
| 108 | EditPart nextColumn = (EditPart)columns.get(index + 1); |
| 109 | for (Iterator i = nextColumn.getChildren().iterator(); i.hasNext(); ) |
| 110 | { |
| 111 | EditPart child = (EditPart)i.next(); |
| 112 | if (child.getModel() == type) |
| 113 | { |
| 114 | return child; |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | return null; |
| 120 | } |
| 121 | |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 122 | private EditPart getTargetConnectionEditPart() |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 123 | { |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 124 | EditPart result = null; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 125 | IField field = (IField)getModel(); |
| 126 | IType type = field.getType(); |
csalter | f42b52e | 2006-05-11 05:20:57 +0000 | [diff] [blame] | 127 | //System.out.println("createConnectionFigure : " + type); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 128 | if (type != null) // && type.isComplexType()) |
| 129 | { |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 130 | result = getTargetEditPart(type); |
| 131 | } |
| 132 | return result; |
| 133 | } |
| 134 | |
| 135 | public TypeReferenceConnection createConnectionFigure() |
| 136 | { |
| 137 | connectionFigure = null; |
| 138 | AbstractGraphicalEditPart referenceTypePart = (AbstractGraphicalEditPart)getTargetConnectionEditPart(); |
| 139 | if (referenceTypePart != null) |
| 140 | { |
| 141 | connectionFigure = new TypeReferenceConnection(); |
| 142 | |
| 143 | if (getFigure().getParent() == referenceTypePart.getFigure()) |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 144 | { |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 145 | connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.LEFT, 1)); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 146 | } |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 147 | else |
| 148 | { |
| 149 | connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(getFigure(), CenteredConnectionAnchor.RIGHT, 5)); |
| 150 | } |
| 151 | int targetAnchorYOffset = 8; |
| 152 | |
| 153 | connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(referenceTypePart.getFigure(), CenteredConnectionAnchor.HEADER_LEFT, 0, targetAnchorYOffset)); |
| 154 | connectionFigure.setHighlight(false); |
| 155 | } |
| 156 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 157 | return connectionFigure; |
| 158 | } |
| 159 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 160 | protected void createEditPolicies() |
| 161 | { |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 162 | super.createEditPolicies(); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 163 | installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, adtDirectEditPolicy); |
kchong | 6360e2a | 2006-04-03 23:50:23 +0000 | [diff] [blame] | 164 | installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ADTSelectionFeedbackEditPolicy()); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 165 | } |
csalter | c7926c0 | 2006-07-18 16:19:46 +0000 | [diff] [blame] | 166 | |
| 167 | public EditPart doGetRelativeEditPart(EditPart editPart, int direction) |
| 168 | { |
| 169 | EditPart result = null; |
| 170 | if (direction == PositionConstants.EAST) |
| 171 | { |
| 172 | result = getTargetConnectionEditPart(); |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | result = super.doGetRelativeEditPart(editPart, direction); |
| 177 | if (result == null) |
| 178 | { |
| 179 | result = ((BaseEditPart)getParent()).doGetRelativeEditPart(editPart, direction); |
| 180 | } |
| 181 | } |
| 182 | return result; |
| 183 | } |
kchong | d4f88a7 | 2006-04-03 23:02:54 +0000 | [diff] [blame] | 184 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 185 | protected void refreshVisuals() |
| 186 | { |
| 187 | super.refreshVisuals(); |
| 188 | IFieldFigure figure = getFieldFigure(); |
| 189 | IField field = (IField) getModel(); |
| 190 | |
| 191 | figure.getNameLabel().setText(field.getName()); |
| 192 | figure.getTypeLabel().setText(field.getTypeName()); |
| 193 | figure.refreshVisuals(getModel()); |
| 194 | |
| 195 | figure.recomputeLayout(); |
| 196 | |
| 197 | ((GraphicalEditPart)getRoot()).getFigure().invalidateTree(); |
| 198 | } |
| 199 | |
| 200 | public DragTracker getDragTracker(Request request) |
| 201 | { |
kchong | 3fab7d5 | 2006-04-19 19:16:06 +0000 | [diff] [blame] | 202 | return new GraphNodeDragTracker(this); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /* |
| 206 | public IAction[] getActions(Object object) |
| 207 | { |
| 208 | // when a FieldEditPart is selected it provides it's own actions |
| 209 | // as well as those of it's parent 'type' edit part |
| 210 | List list = new ArrayList(); |
| 211 | EditPart compartment = getParent(); |
| 212 | if (compartment != null) |
| 213 | { |
| 214 | EditPart type = compartment.getParent(); |
| 215 | if (type != null && type instanceof IActionProvider) |
| 216 | { |
| 217 | IActionProvider provider = (IActionProvider)type; |
| 218 | addActionsToList(list, provider.getActions(object)); |
| 219 | } |
| 220 | } |
| 221 | addActionsToList(list, super.getActions(object)); |
| 222 | IAction[] result = new IAction[list.size()]; |
| 223 | list.toArray(result); |
| 224 | return result; |
| 225 | }*/ |
| 226 | |
| 227 | public Label getNameLabelFigure() |
| 228 | { |
| 229 | return getFieldFigure().getNameLabel(); |
| 230 | } |
| 231 | |
| 232 | public void performDirectEdit(Point cursorLocation) |
| 233 | { |
| 234 | |
| 235 | } |
| 236 | |
| 237 | public void performRequest(Request request) |
| 238 | { |
kchong | 1410efb | 2006-04-27 18:48:05 +0000 | [diff] [blame] | 239 | if (((IADTObject)getModel()).isReadOnly()) |
| 240 | { |
| 241 | return; |
| 242 | } |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 243 | if (request.getType() == RequestConstants.REQ_DIRECT_EDIT|| |
| 244 | request.getType() == RequestConstants.REQ_OPEN) |
| 245 | { |
| 246 | IFieldFigure fieldFigure = getFieldFigure(); |
| 247 | Object model = getModel(); |
| 248 | if (request instanceof LocationRequest) |
| 249 | { |
| 250 | LocationRequest locationRequest = (LocationRequest)request; |
| 251 | Point p = locationRequest.getLocation(); |
| 252 | |
| 253 | if (hitTest(fieldFigure.getTypeLabel(), p)) |
| 254 | { |
| 255 | TypeReferenceDirectEditManager manager = new TypeReferenceDirectEditManager((IField)model, this, fieldFigure.getTypeLabel()); |
| 256 | typeUpdateCommand.setDelegate(manager); |
| 257 | adtDirectEditPolicy.setUpdateCommand(typeUpdateCommand); |
| 258 | manager.show(); |
| 259 | } |
| 260 | else if (hitTest(fieldFigure.getNameLabel(), p)) |
| 261 | { |
rmah | a18ac08 | 2006-07-24 17:32:26 +0000 | [diff] [blame] | 262 | directEditNameField(); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 263 | } |
| 264 | } |
rmah | a18ac08 | 2006-07-24 17:32:26 +0000 | [diff] [blame] | 265 | else { |
| 266 | directEditNameField(); |
| 267 | } |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
rmah | a18ac08 | 2006-07-24 17:32:26 +0000 | [diff] [blame] | 271 | private void directEditNameField() { |
| 272 | Object model = getModel(); |
| 273 | IFieldFigure fieldFigure = getFieldFigure(); |
| 274 | if ( model instanceof IField) |
| 275 | { |
| 276 | IField field = (IField) model; |
| 277 | if (field.isReference()) |
| 278 | { |
| 279 | ElementReferenceDirectEditManager manager = new ElementReferenceDirectEditManager((IField) model, this, fieldFigure.getNameLabel()); |
| 280 | elementUpdateCommand.setDelegate(manager); |
| 281 | adtDirectEditPolicy.setUpdateCommand(elementUpdateCommand); |
| 282 | manager.show(); |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | LabelEditManager manager = new LabelEditManager(this, new LabelCellEditorLocator(this, null)); |
| 287 | NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); |
| 288 | adtDirectEditPolicy.setUpdateCommand(wrapper); |
| 289 | manager.show(); |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
kchong | bd37beb | 2006-05-13 18:38:38 +0000 | [diff] [blame] | 294 | public void doEditName(boolean addFromDesign) |
| 295 | { |
| 296 | if (!addFromDesign) return; |
| 297 | |
| 298 | // removeFeedback(); |
| 299 | |
kchong | f9510bf | 2006-09-05 21:28:47 +0000 | [diff] [blame] | 300 | Runnable runnable = new Runnable() |
| 301 | { |
| 302 | public void run() |
| 303 | { |
kchong | bd37beb | 2006-05-13 18:38:38 +0000 | [diff] [blame] | 304 | Object object = ((XSDBaseAdapter)getModel()).getTarget(); |
| 305 | if (object instanceof XSDNamedComponent) |
| 306 | { |
| 307 | Point p = getNameLabelFigure().getLocation(); |
| 308 | LabelEditManager manager = new LabelEditManager(BaseFieldEditPart.this, new LabelCellEditorLocator(BaseFieldEditPart.this, p)); |
| 309 | NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper(); |
| 310 | adtDirectEditPolicy.setUpdateCommand(wrapper); |
| 311 | manager.show(); |
| 312 | } |
kchong | f9510bf | 2006-09-05 21:28:47 +0000 | [diff] [blame] | 313 | } |
| 314 | }; |
| 315 | Display.getCurrent().asyncExec(runnable); |
kchong | bd37beb | 2006-05-13 18:38:38 +0000 | [diff] [blame] | 316 | |
| 317 | } |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 318 | |
| 319 | class NameUpdateCommandWrapper extends Command implements IADTUpdateCommand |
| 320 | { |
| 321 | Command command; |
| 322 | protected DirectEditRequest request; |
| 323 | |
| 324 | public NameUpdateCommandWrapper() |
| 325 | { |
kchong | 83beb0b | 2006-04-12 21:55:41 +0000 | [diff] [blame] | 326 | super(Messages._UI_ACTION_UPDATE_NAME); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | public void setRequest(DirectEditRequest request) |
| 330 | { |
| 331 | this.request = request; |
| 332 | } |
| 333 | |
| 334 | public void execute() |
| 335 | { |
| 336 | IField field = (IField)getModel(); |
| 337 | Object newValue = request.getCellEditor().getValue(); |
| 338 | if (newValue instanceof String) |
| 339 | { |
| 340 | command = field.getUpdateNameCommand((String)newValue); |
| 341 | } |
| 342 | if (command != null) |
| 343 | command.execute(); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | class TypeUpdateCommand extends Command implements IADTUpdateCommand |
| 348 | { |
| 349 | protected ComboBoxCellEditorManager delegate; |
| 350 | protected DirectEditRequest request; |
| 351 | |
| 352 | public TypeUpdateCommand() |
| 353 | { |
kchong | 83beb0b | 2006-04-12 21:55:41 +0000 | [diff] [blame] | 354 | super(Messages._UI_ACTION_UPDATE_TYPE); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | public void setDelegate(ComboBoxCellEditorManager delegate) |
| 358 | { |
| 359 | this.delegate = delegate; |
| 360 | } |
| 361 | |
| 362 | public void setRequest(DirectEditRequest request) |
| 363 | { |
| 364 | this.request = request; |
| 365 | } |
| 366 | |
| 367 | public void execute() |
| 368 | { |
| 369 | if (delegate != null) |
| 370 | { |
| 371 | delegate.performEdit(request.getCellEditor()); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | public boolean canExecute() |
| 376 | { |
kchong | 43dd1cc | 2006-07-24 16:48:58 +0000 | [diff] [blame] | 377 | IField field = (IField)getModel(); |
| 378 | Object newValue = ((CCombo)request.getCellEditor().getControl()).getText(); |
| 379 | if (newValue instanceof String) |
| 380 | { |
| 381 | return !newValue.equals(field.getTypeName()); |
| 382 | } |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 383 | return true; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | class ElementReferenceUpdateCommand extends Command implements IADTUpdateCommand |
| 388 | { |
| 389 | protected ComboBoxCellEditorManager delegate; |
| 390 | protected DirectEditRequest request; |
| 391 | |
| 392 | public ElementReferenceUpdateCommand() |
| 393 | { |
kchong | 83beb0b | 2006-04-12 21:55:41 +0000 | [diff] [blame] | 394 | super(Messages._UI_ACTION_UPDATE_ELEMENT_REFERENCE); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | public void setDelegate(ComboBoxCellEditorManager delegate) |
| 398 | { |
| 399 | this.delegate = delegate; |
| 400 | } |
| 401 | |
| 402 | public void setRequest(DirectEditRequest request) |
| 403 | { |
| 404 | this.request = request; |
| 405 | } |
| 406 | |
| 407 | public void execute() |
| 408 | { |
| 409 | if (delegate != null) |
| 410 | { |
| 411 | delegate.performEdit(request.getCellEditor()); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | public boolean canExecute() |
| 416 | { |
| 417 | return true; |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 422 | public void addFeedback() |
| 423 | { |
| 424 | // Put back connection figure so it won't get overlayed by other non highlighted connections |
| 425 | if (connectionFigure != null) |
| 426 | { |
| 427 | connectionFeedbackFigure = new TypeReferenceConnection(); |
| 428 | connectionFeedbackFigure.setSourceAnchor(connectionFigure.getSourceAnchor()); |
| 429 | connectionFeedbackFigure.setTargetAnchor(connectionFigure.getTargetAnchor()); |
| 430 | connectionFeedbackFigure.setHighlight(true); |
| 431 | getLayer(LayerConstants.FEEDBACK_LAYER).add(connectionFeedbackFigure); |
| 432 | } |
| 433 | super.addFeedback(); |
| 434 | getFieldFigure().addSelectionFeedback(); |
| 435 | } |
| 436 | |
| 437 | public void removeFeedback() |
| 438 | { |
| 439 | if (connectionFeedbackFigure != null) |
| 440 | { |
| 441 | connectionFeedbackFigure.setHighlight(false); |
| 442 | getLayer(LayerConstants.FEEDBACK_LAYER).remove(connectionFeedbackFigure); |
| 443 | } |
| 444 | connectionFeedbackFigure = null; |
| 445 | super.removeFeedback(); |
| 446 | getFieldFigure().removeSelectionFeedback(); |
| 447 | } |
| 448 | } |
| 449 | |