001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.api.designer;
043:
044: import java.awt.Component;
045: import java.awt.Dimension;
046: import java.awt.FontMetrics;
047: import java.awt.Point;
048: import java.awt.Rectangle;
049: import java.awt.datatransfer.Transferable;
050: import java.awt.event.ActionEvent;
051: import java.io.PrintStream;
052: import java.io.PrintWriter;
053: import java.util.EventListener;
054: import javax.swing.Action;
055: import javax.swing.ActionMap;
056: import javax.swing.JComponent;
057: import org.netbeans.modules.visualweb.api.designer.DomProvider.DomPosition;
058: import org.netbeans.modules.visualweb.api.designer.DomProvider.DomRange;
059: import org.netbeans.modules.visualweb.designer.html.HtmlTag;
060: import org.openide.util.Lookup;
061: import org.w3c.dom.Element;
062: import org.w3c.dom.Node;
063:
064: /**
065: * Interface representing the designer component.
066: *
067: * @author Peter Zavadsky
068: */
069: public interface Designer {
070:
071: // public JComponent getDesignerComponent();
072:
073: // // XXX Temp after moved TopComponent impl out >>>
074: // public JComponent getVisualRepresentation();
075: // public JComponent getToolbarRepresentation();
076: // public Action[] getActions();
077: // public Lookup getLookup();
078: // public void componentOpened();
079: // public void componentClosed();
080: // public void componentShowing();
081: // public void componentHidden();
082: // public void componentActivated();
083: // public void componentDeactivated();
084: // public UndoRedo getUndoRedo();
085: // public void setMultiViewCallback(MultiViewElementCallback multiViewElementCallback);
086: // public CloseOperationState canCloseElement();
087: // // XXX Temp after moved TopComponent impl out <<<
088:
089: public void startInlineEditing(Element componentRootElement,
090: String propertyName);
091:
092: public void finishInlineEditing(boolean cancel);
093:
094: public boolean isInlineEditing();
095:
096: public void inlineEditComponents(Element[] componentRootElements);
097:
098: // XXX Hack
099: public void invokeDeleteNextCharAction(ActionEvent evt);
100:
101: // XXX
102: public Transferable inlineCopyText(boolean isCut);
103:
104: public void selectComponent(Element componentRootElement);
105:
106: // XXX This is bad, get rid of.
107: public void selectComponentDelayed(Element componentRootElement);
108:
109: public int getSelectedCount();
110:
111: /** Gets selected componets (component root elements). */
112: public Element[] getSelectedComponents();
113:
114: // XXX Suspicious? Also pick up if not ready.
115: public Element getPrimarySelectedComponent();
116:
117: // XXX See above (this one doesn't pick up)
118: public Element getPrimarySelection();
119:
120: public Element getSelectedContainer();
121:
122: // XXX Modification, get rid of update parameter.
123: public void setSelectedComponents(Element[] componentRootElements,
124: boolean update);
125:
126: public void clearSelection(boolean update);
127:
128: // XXX Get rid of
129: public void syncSelection(boolean update);
130:
131: // XXX Get rid of
132: public void updateSelectedNodes();
133:
134: // // XXX Get rid of
135: //// public void updateSelection();
136: // public void updateNodes();
137:
138: // public enum Alignment {
139: // SNAP_TO_GRID,
140: // TOP,
141: // MIDDLE,
142: // BOTTOM,
143: // LEFT,
144: // CENTER,
145: // RIGHT
146: // }
147: // public void align(Alignment alignment);
148: // public void snapToGrid();
149:
150: // XXX Move to document >>>
151: public DomPosition computeNextPosition(DomPosition pos);
152:
153: public DomPosition computePreviousPosition(DomPosition pos);
154:
155: public boolean isInsideEditableRegion(DomPosition pos);
156:
157: // XXX Move to document <<<
158:
159: // >>> Boxes stuff
160: /** Representing the individual box. Providing accessors (getters) only! */
161: public interface Box {
162: // XXX Get rid of this. See CssBox.UNINITIALIZED.
163: public static final int UNINITIALIZED = Integer.MAX_VALUE - 2; // debugging
164:
165: public Element getComponentRootElement();
166:
167: public Element getElement();
168:
169: public Box getParent();
170:
171: public Box[] getChildren();
172:
173: // XXX Get rid of this.
174: public HtmlTag getTag();
175:
176: // XXX Get rid of this.
177: public Element getSourceElement();
178:
179: public int getWidth();
180:
181: public int getHeight();
182:
183: public int getBlockWidth();
184:
185: public int getBlockHeight();
186:
187: public int getX();
188:
189: public int getY();
190:
191: public int getZ();
192:
193: public int getAbsoluteX();
194:
195: public int getAbsoluteY();
196:
197: public int getRightMargin();
198:
199: public int getLeftMargin();
200:
201: public int getEffectiveTopMargin();
202:
203: // XXX Get rid of.
204: public boolean isPositioned();
205:
206: public boolean isAbsolutelyPositioned();
207:
208: // XXX Very suspicious.
209: public Box getPositionedBy();
210:
211: public void list(PrintStream outputStream, int indent);
212:
213: public void list(PrintWriter writer, int indent);
214: } // End of Box.
215:
216: /** Box representing external page (e.g. fragment). */
217: public interface ExternalBox extends Box {
218: public DomProvider getExternalDomProvider();
219: } // End od ExternalBox.
220:
221: public Box getPageBox();
222:
223: public Box findBox(int x, int y);
224:
225: // XXX Get rid of.
226: public Box findBoxForSourceElement(Element sourceElement);
227:
228: public Box findBoxForComponentRootElement(
229: Element componentRootElement);
230:
231: // XXX Get rid of.
232: public Box findBoxForElement(Element element);
233:
234: public int snapX(int x, Box positionedBy);
235:
236: public int snapY(int y, Box positionedBy);
237:
238: // <<< Boxes stuff
239:
240: // public Point getCurrentPos();
241: // public void clearCurrentPos();
242: // public Element getPositionElement();
243: // public int getGridWidth();
244: // public int getGridHeight();
245:
246: public Point getPastePoint();
247:
248: // // XXX Designer settings properties
249: // /** show grid */
250: // public static final String PROP_GRID_SHOW = "gridShow"; // NOI18N
251: // public static final String PROP_GRID_SNAP = "gridSnap"; // NOI18N
252: // public static final String PROP_GRID_WIDTH = "gridWidth"; // NOI18N
253: // public static final String PROP_GRID_HEIGHT = "gridHeight"; // NOI18N
254: // public static final String PROP_PAGE_SIZE = "pageSize"; // NOI18N
255: // public static final String PROP_SHOW_DECORATIONS = "showDecorations"; // NOI18N
256: // public static final String PROP_DEFAULT_FONT_SIZE = "defaultFontSize"; // NOI18N
257: // // XXX Make not weak, and also add removal
258: // public void addWeakPreferenceChangeListener(PreferenceChangeListener l);
259:
260: // public void registerListeners();
261: // public void unregisterListeners();
262:
263: public ActionMap getPaneActionMap();
264:
265: public void paneRequestFocus();
266:
267: // XXX This should be the designer itself.
268: public JComponent createPaneComponent();
269:
270: // XXX Get rid of.
271: public void updatePaneViewPort();
272:
273: public boolean hasPaneCaret();
274:
275: public DomRange getPaneCaretRange();
276:
277: public void setPaneCaret(DomPosition pos);
278:
279: public void resetPanePageBox();
280:
281: public void redoPaneLayout(boolean immediate);
282:
283: // public void setRenderFailureShown(boolean shown);
284: // public boolean isRenderFailureShown();
285: // public void updateErrors();
286: // public void showErrors(boolean on);
287:
288: // public void updateGridMode();
289:
290: // // XXX Get rid of this
291: // public void performEscape();
292:
293: public void resetAll();
294:
295: public void changeNode(Node node, Node parent,
296: Element[] changedElements);
297:
298: public void removeNode(Node node, Node parent);
299:
300: public void insertNode(Node node, Node parent);
301:
302: public void setPaneGrid(boolean gridMode);
303:
304: public void detachDomDocument();
305:
306: public void showDropMatch(Element componentRootElement,
307: Element regionElement, int dropType);
308:
309: public void clearDropMatch();
310:
311: public void addDesignerListener(DesignerListener l);
312:
313: public void removeDesignerListener(DesignerListener l);
314:
315: public interface DesignerListener extends EventListener {
316: /** When user performed action on the box. */
317: public void userActionPerformed(DesignerEvent evt);
318:
319: /** When user invoked popup. */
320: public void userPopupActionPerformed(DesignerPopupEvent evt);
321:
322: /** When user clicked on some element. */
323: public void userElementClicked(DesignerClickEvent evt);
324:
325: /** When selection was changed. */
326: public void selectionChanged(DesignerEvent evt);
327: } // End of DesignerListener.
328:
329: public interface DesignerEvent {
330: public Designer getDesigner();
331:
332: public Box getBox();
333: } // End of DesignerEvent.
334:
335: public interface DesignerPopupEvent extends DesignerEvent {
336: public Component getComponent();
337:
338: public Action[] getActions();
339:
340: public Lookup getContext();
341:
342: public int getX();
343:
344: public int getY();
345: } // End of DesignerPopupEvent.
346:
347: public interface DesignerClickEvent extends DesignerEvent {
348: public boolean isConsumed();
349:
350: public void consume();
351:
352: public int getClickCount();
353: } // DesignerClickEvent
354:
355: /** XXX Render Context. */
356: public interface RenderContext {
357: // public DesignBean[] getBeansOfType(Class clazz);
358: public Dimension getVieportDimension();
359:
360: public Point getViewportPosition();
361:
362: public int getNonTabbedTextWidth(char[] s, int offset,
363: int length, FontMetrics metrics);
364:
365: // public Rectangle getBoundsForDesignBean(DesignBean designBean);
366: public Rectangle getBoundsForComponent(
367: Element componentRootElement);
368: } // End of RenderContext.
369:
370: public RenderContext createRenderContext();
371:
372: public DomProvider[] getExternalDomProviders();
373:
374: /** Sets whether to paint size mask, typically used for fragments and portlets. */
375: public void setPaintSizeMask(boolean paintSizeMask);
376:
377: /** Specifies whether the component paints size mask. */
378: public boolean isPaintSizeMask();
379:
380: // public void setPageSizeWidth(int pageSizeWidth);
381: // public void setPageSizeHeight(int pageSizeHeight);
382: public void setPageSize(Dimension pageSize);
383:
384: public void setGridShow(boolean gridShow);
385:
386: public void setGridSnap(boolean gridSnap);
387:
388: public void setGridWidth(int gridWidth);
389:
390: public void setGridHeight(int gridHeight);
391:
392: public void setGridTraceWidth(int gridTraceWidth);
393:
394: public void setGridTraceHeight(int gridTraceHeight);
395:
396: public void setShowDecorations(boolean showDecorations);
397:
398: public void setDefaultFontSize(int defaultFontSize);
399:
400: public void copyBoxForElement(Element fromElement, Element toElement);
401: }
|