001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package net.refractions.udig.printing.ui.internal.editor.parts;
018:
019: import net.refractions.udig.printing.model.Box;
020: import net.refractions.udig.printing.model.PropertyListener;
021: import net.refractions.udig.printing.ui.internal.editor.policies.PageElementEditPolicy;
022:
023: import org.eclipse.gef.EditPolicy;
024: import org.eclipse.gef.editparts.AbstractTreeEditPart;
025:
026: /**
027: * Provides ...TODO summary sentence
028: * <p>
029: * TODO Description
030: * </p><p>
031: * Responsibilities:
032: * <ul>
033: * <li>
034: * <li>
035: * </ul>
036: * </p><p>
037: * Example Use:<pre><code>
038: * BoxTreeEditPart x = new BoxTreeEditPart( ... );
039: * TODO code example
040: * </code></pre>
041: * </p>
042: * @author Richard Gould
043: * @since 0.3
044: */
045: public class BoxTreeEditPart extends AbstractTreeEditPart {
046:
047: private InternalPropertyListener listener = new InternalPropertyListener();
048:
049: /**
050: * Construct <code>BoxTreeEditPart</code>.
051: *
052: * @param model
053: */
054: public BoxTreeEditPart(Box model) {
055: super (model);
056: }
057:
058: /**
059: * TODO summary sentence for activate ...
060: *
061: * @see org.eclipse.gef.EditPart#activate()
062: *
063: */
064: public void activate() {
065: if (isActive()) {
066: return;
067: }
068: super .activate();
069: ((Box) getModel()).eAdapters().add(this .listener);
070: }
071:
072: /**
073: * TODO summary sentence for deactivate ...
074: *
075: * @see org.eclipse.gef.EditPart#deactivate()
076: *
077: */
078: public void deactivate() {
079: if (!isActive()) {
080: return;
081: }
082: super .deactivate();
083: ((Box) getModel()).eAdapters().remove(this .listener);
084: }
085:
086: /**
087: * TODO summary sentence for createEditPolicies ...
088: *
089: * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
090: *
091: */
092: protected void createEditPolicies() {
093: installEditPolicy(EditPolicy.COMPONENT_ROLE,
094: new PageElementEditPolicy());
095: }
096:
097: /**
098: * TODO summary sentence for refreshVisuals ...
099: *
100: * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
101: *
102: */
103: protected void refreshVisuals() {
104: setWidgetText(getModel().toString());
105: }
106:
107: private class InternalPropertyListener extends PropertyListener {
108:
109: /**
110: * TODO summary sentence for locationChanged ...
111: *
112: * @see net.refractions.udig.printing.model.PropertyListener#locationChanged()
113: *
114: */
115: protected void locationChanged() {
116: refreshVisuals();
117: }
118:
119: /**
120: * TODO summary sentence for sizeChanged ...
121: *
122: * @see net.refractions.udig.printing.model.PropertyListener#sizeChanged()
123: *
124: */
125: protected void sizeChanged() {
126: refreshVisuals();
127: }
128: }
129: }
|