01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.printing.ui.internal.editor.policies;
18:
19: import net.refractions.udig.printing.model.Box;
20: import net.refractions.udig.printing.model.impl.LabelBoxPrinter;
21: import net.refractions.udig.printing.ui.internal.editor.commands.RenameLabelCommand;
22: import net.refractions.udig.printing.ui.internal.editor.figures.BoxFigure;
23:
24: import org.eclipse.gef.commands.Command;
25: import org.eclipse.gef.editpolicies.DirectEditPolicy;
26: import org.eclipse.gef.requests.DirectEditRequest;
27:
28: /**
29: * Allows the text of a label to be edited.
30: *
31: * @author Richard Gould
32: * @since 0.3
33: */
34: public class LabelDirectEditPolicy extends DirectEditPolicy {
35:
36: protected Command getDirectEditCommand(DirectEditRequest request) {
37: RenameLabelCommand cmd = new RenameLabelCommand();
38: cmd.setNode((LabelBoxPrinter) ((Box) getHost().getModel())
39: .getBoxPrinter());
40: cmd.setName((String) request.getCellEditor().getValue());
41: return cmd;
42: }
43:
44: protected void showCurrentEditValue(DirectEditRequest request) {
45: String value = (String) request.getCellEditor().getValue();
46: ((BoxFigure) getHostFigure()).setName(value);
47: }
48: }
|