001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.soa.mapper.common.basicmapper;
021:
022: import java.awt.Component;
023: import java.util.Collection;
024: import java.util.List;
025:
026: import javax.swing.Icon;
027: import javax.swing.tree.TreePath;
028:
029: import org.netbeans.modules.soa.mapper.common.basicmapper.literal.ILiteralUpdater;
030: import org.netbeans.modules.soa.mapper.common.basicmapper.literal.ILiteralUpdaterFactory;
031: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IField;
032: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IFieldNode;
033: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IMethoid;
034: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IMethoidNode;
035: import org.netbeans.modules.soa.mapper.common.basicmapper.palette.IPaletteView;
036: import org.netbeans.modules.soa.mapper.common.basicmapper.tree.IMapperTreeNode;
037: import org.netbeans.modules.soa.mapper.common.IMapperEvent;
038: import org.netbeans.modules.soa.mapper.common.IMapperLink;
039: import org.netbeans.modules.soa.mapper.common.IMapperListener;
040: import org.netbeans.modules.soa.mapper.common.IMapperNode;
041:
042: /**
043: * <p>
044: *
045: * Title: Mapper Interface </p> <p>
046: *
047: * Description: Generic interface describe a mapper component. This Mapper
048: * should be the only instance that add or remove link and group node into
049: * model, within the design of Mapper. Without a MapperRule set to a mapper. No
050: * link or group node should be created or removed unless some other customize
051: * MapperListener listen on those request events and calls new or remove link
052: * and group node of this interface, accordingly. </p> <p>
053: *
054: * The design of Mapper framework provides as much as flexiblility for caller to
055: * provides its own implementation base on the default implemenation. However,
056: * the base line is not able to change the java.awt.Component that this mapper
057: * views repersents, except palette view. For Example: To add this mapper to a
058: * window, you can <pre>
059: * public class MapperWin extends JFrame () {
060: *
061: * public MapperWin () {
062: * IBasicMapper mapper = (get a reference of mapper implementation)
063: * this.getContentPane().add (mapper.getVisualMapper(), BorderLayout.CENTER);
064: * ...
065: * ...
066: * }
067: * }
068: * </pre> To provide a customized canvas field node, proivdes a new class that
069: * implements ICanvasObjectFactory and set the customized factory to the canvas.
070: * <pre>
071: * class MyFactory implements ICanvasObjectFactory {
072: * ICanvasObjectFactory defaultFactory;
073: * public MyFactory (ICanvasObjectFactory defaultFactory) {
074: * this.defaultFactory = defaultFoctory;
075: * }
076: *
077: * ....
078: * ....
079: *
080: * public ICanvasMapperLink createLink(IMapperLink link) {
081: * return defaultFactory.createLink(link);
082: * }
083: *
084: * public ICanvasFieldNode createFieldNode(IMapperFieldNode node) {
085: * ICanvasFieldNode customizedNode = (do your own implemnatin of field node).
086: * ....
087: * ....
088: * return customizedNode;
089: * }
090: * }
091: *
092: * class MyMapper {
093: *
094: * public void initialize() {
095: * IBasicMapper mapper = (get a reference of mapper implementation)
096: * ICanvasObjectFactory defaultFactory =
097: * mapper.getMapperViewManager().getCanvasView()
098: * .getCanvas().getCanvasObjectFactory();
099: * mapper.getMapperViewManager().getCanvasView()
100: * .getCanvas().setCanvasObjectFactory (new MyFactory (defaultFactory));
101: * ....
102: * ....
103: * }
104: * }
105: * </pre> Copyright: Copyright (c) 2002 </p> <p>
106: *
107: * Company: </p>
108: *
109: * @author Un Seng Leong
110: * @created December 4, 2002
111: * @version 1.0
112: */
113: public interface IBasicMapper {
114:
115: /**
116: * Return the model of this mapper.
117: *
118: * @return the model of this mapper displaying.
119: */
120: public IBasicMapperModel getMapperModel();
121:
122: /**
123: * Set the mapper model to this mapper.
124: *
125: * @param mapperModel the model to be displayed
126: */
127: public void setMapperModel(IBasicMapperModel mapperModel);
128:
129: /**
130: * Create a new default basic mapper model.
131: *
132: * @return a new default basic mapper model.
133: */
134: public IBasicMapperModel createDefaultMapperModel();
135:
136: /**
137: * Create a new default basic view model.
138: *
139: * @return a new default basic view model.
140: */
141: public IBasicViewModel createDefaultViewModel();
142:
143: /**
144: * Copy visited nodes and links by the specified link to the model. This
145: * method does not aggressively copy all the links in a mapper tree node. It
146: * copy those tree links when visited. It treats mapper tree node is either
147: * start point of a chain of end point of a chain.
148: *
149: * @param link the link of the chain start point
150: * @param model the model to put the link in.
151: * @return the new link that connects with the new chain
152: */
153: public IMapperLink copyDirectedChain(IMapperLink link,
154: IBasicViewModel model);
155:
156: /**
157: * Copy visited nodes and links by the specified node to the model. This
158: * method does not aggressively copy all the links in a mapper tree node. It
159: * copy those tree links when visited. It treats mapper tree node is either
160: * start point of a chain of end point of a chain. If the specified node is
161: * a mapper tree node, a copy of the tree node will be returned.
162: *
163: * @param node the node of the chain start point
164: * @param model the model to put the link in.
165: * @return the new node that connects with the new chain
166: */
167: public IMapperNode copyDirectedChain(IMapperNode node,
168: IBasicViewModel model);
169:
170: /**
171: * Remove a directed chian start from the specified link. The method remove
172: * all the links and nodes that it visites, however, it will not
173: * aggressively remove all the tree node links, only remove the one is
174: * visited.
175: *
176: * @param link the link of the chian start point
177: * @param model the model that contains all the chain nodes
178: */
179: public void removeDirectedChain(IMapperLink link,
180: IBasicViewModel model);
181:
182: /**
183: * Remove a directed chian start from the specified node. The method remove
184: * all the links and nodes that it visites, however, it will not
185: * aggressively remove all the tree node links, only remove the one is
186: * visited.
187: *
188: * @param model the model that contains all the chain nodes
189: * @param node Description of the Parameter
190: */
191: public void removeDirectedChain(IMapperNode node,
192: IBasicViewModel model);
193:
194: /**
195: * Move a directed chain, start by the specified link, from the old model,
196: * to the new model.
197: *
198: * @param link the chain start point
199: * @param oldModel the old model which the chain nodes will be removed
200: * from.
201: * @param newModel the new model which the chain nodes will be stored to.
202: */
203: public void moveDirectedChain(IMapperLink link,
204: IBasicViewModel oldModel, IBasicViewModel newModel);
205:
206: /**
207: * Move a directed chain, start by the specified node, from the old model,
208: * to the new model.
209: *
210: * @param node the chain start point
211: * @param oldModel the old model which the chain nodes will be removed
212: * from.
213: * @param newModel the new model which the chain nodes will be stored to.
214: */
215: public void moveDirectedChain(IMapperNode node,
216: IBasicViewModel oldModel, IBasicViewModel newModel);
217:
218: /**
219: * Set the mapper rule that handle the permissions of creating mapper
220: * object.
221: *
222: * @param rule the mapper rule of this mapper.
223: */
224: public void setMapperRule(IBasicMapperRule rule);
225:
226: /**
227: * Return the mapper rule that handles the permissions of creating mapper
228: * object.
229: *
230: * @return DOCUMENT ME!
231: */
232: public IBasicMapperRule getMapperRule();
233:
234: /**
235: * Create a default mapper rule.
236: *
237: * @return a default mapper rule.
238: */
239: public IBasicMapperRule createDefaultMapperRule();
240:
241: /**
242: * Retrun a mapper link that connects the fromNode to toNode.
243: *
244: * @param fromNode the start node of the link
245: * @param toNode the end node of the link
246: * @return a mapper link that connects the fromNode to toNode.
247: */
248: public IMapperLink createLink(IMapperNode fromNode,
249: IMapperNode toNode);
250:
251: /**
252: * Connected the sepecified link to its contained node.
253: *
254: * @param link the link to be connected
255: */
256: public void connectLink(IMapperLink link);
257:
258: /**
259: * Return a methoid field with all the specified basic field information.
260: *
261: * @param name the name of this field.
262: * @param type the tyoe of this field.
263: * @param tooltip the tooltip text of this field
264: * @param data the data object of this field
265: * @param isInput flag indicates if this is an input field
266: * @param isOutput flag indicates if this is an output field
267: * @param literalInfo optional literal info
268: * @return Description of the Return Value
269: */
270: public IField createField(String name, String type, String tooltip,
271: Object data, boolean isInput, boolean isOutput,
272: ILiteralUpdater literalUpdater);
273:
274: /**
275: * Return a field Node with the specified field.
276: *
277: * @param field the field of the node.
278: * @return a field Node with the specified field.
279: */
280: public IFieldNode createFieldNode(IField field);
281:
282: /**
283: * Return a newly created mapper node with the specified methoid object.
284: *
285: * @param methoid the methoid object of this mapper node repersents.
286: * @return Description of the Return Value
287: */
288: public IMethoidNode createMethoidNode(IMethoid methoid);
289:
290: /**
291: * Return a new mapper event by specifying the properties of the event.
292: *
293: * @param source the source of the event.
294: * @param transferData the data object to be transfer.
295: * @param eventType the type of the event.
296: * @param eventDesc the description of the event.
297: * @return a new mapper event by specifying the properties of
298: * the event.
299: */
300: public IMapperEvent createMapperEvent(Object source,
301: Object transferData, String eventType, String eventDesc);
302:
303: /**
304: * Return a new methoid object with specified all properties of the methoid.
305: *
306: * @param icon the icon of this methoid.
307: * @param name the name of this funcotid.
308: * @param tooltip the tooltip of this methoid.
309: * @param data the data of this methoid.
310: * @param namespace the namespace of this methoid.
311: * @param inputFields the input fields of this methoid.
312: * @param outputFields the output fields of this methoid.
313: * @param isAccumulative whether the input fields can grow dynamically
314: * @return a new methoid object with specified all properties
315: * of the methoid.
316: */
317: public IMethoid createMethoid(Icon icon, String name,
318: String tooltip, Object data, IField namespace,
319: List inputFields, List outputFields,
320: boolean isAccumulative, boolean isLiteral);
321:
322: /**
323: * Return a new mapper tree node that contains the specified tree path from
324: * the specified tree.
325: *
326: * @param treePath the tree path to be store in the mapper tree node.
327: * @param isSourceTree true if the the mapper tree node is from source
328: * tree, false otherwise.
329: * @return a new mapper tree node of the specified tree that
330: * contains the specified tree path.
331: */
332: public IMapperTreeNode createMapperTreeNode(TreePath treePath,
333: boolean isSourceTree);
334:
335: /**
336: * Add a link to this mapper.
337: *
338: * @param link the link to be added.
339: */
340: public void addLink(IMapperLink link);
341:
342: /**
343: * Add a node to this mapper.
344: *
345: * @param node the group node to be added.
346: */
347: public void addNode(IMapperNode node);
348:
349: /**
350: * Add a list of mapper object into the specified mode.
351: *
352: * @param mapperObjs the list of mapper object to be added
353: * @param model the model to store the objects.
354: */
355: public void addObjectsToModel(Collection mapperObjs,
356: IBasicViewModel model);
357:
358: /**
359: * Remove a link from this mapper.
360: *
361: * @param link the link will be removed from this mapper.
362: */
363: public void removeLink(IMapperLink link);
364:
365: /**
366: * Remove a node node from this mapper.
367: *
368: * @param node the group node will be removed from this mapper.
369: */
370: public void removeNode(IMapperNode node);
371:
372: /**
373: * Return true is mapping enable, false otherwise. Mapping enable allows
374: * user to use mapper normal, if disable, no mouse event goes through the
375: * mapper.
376: *
377: * @return Return true is mapping enable, false otherwise.
378: */
379: public boolean isMappingEnable();
380:
381: /**
382: * Sets if mapping enable. Mapping enable allows user to use mapper normal,
383: * if disable, no mouse event goes through the mapper.
384: *
385: * @param isMappingEnable true is mapping enable, false otherwise.
386: */
387: public void setMappingEnable(boolean isMappingEnable);
388:
389: /**
390: * Set the palette view of this mapper.
391: *
392: * @param paletteView the palette of this mapper.
393: */
394: public void setPalette(IPaletteView paletteView);
395:
396: /**
397: * Return the palette view of this mapper.
398: *
399: * @return the palette view of this mapper.
400: */
401: public IPaletteView getPalette();
402:
403: /**
404: * Return the view manager of this mapper.
405: *
406: * @return the view manager of this mapper.
407: */
408: public IBasicViewManager getMapperViewManager();
409:
410: /**
411: * Return the mapper controller.
412: *
413: * @return the mapper controller.
414: */
415: public IBasicController getMapperController();
416:
417: /**
418: * Return the visual repersentation of this mapper.
419: *
420: * @return the visual repersentation of this mapper.
421: */
422: public Component getVisualMapper();
423:
424: /**
425: * Add a mapper listener to listening to mapper events. Available mapper
426: * Event is defined in IMapperEvent.
427: *
428: * @param listener the mapper listener to be added.
429: */
430: public void addMapperListener(IMapperListener listener);
431:
432: /**
433: * Remove a mapper listener from this mapper.
434: *
435: * @param listener the mapper listener to be removed.
436: */
437: public void removeMapperListener(IMapperListener listener);
438:
439: /**
440: * Return the viewable size factor of the total width betweem the
441: * destination tree view and the mapper when the mapper first show up to the
442: * screen.
443: *
444: * @return the destination tree viewable size weight
445: */
446: public float getInitialDestTreeViewableWeight();
447:
448: /**
449: * Set the viewable size factor of the total width betweem the destination
450: * tree view and the mapper when the mapper first show up to the screen.
451: *
452: * @param destTreeWeight the destination tree viewable size weight.
453: */
454: public void setInitialDestTreeViewableWeight(float destTreeWeight);
455:
456: /**
457: * Return the viewable size factor of the total width betweem the
458: * destination tree view and the mapper when the mapper first show up to the
459: * screen.
460: *
461: * @return the source tree viewable size weight
462: */
463: public float getInitialSourceTreeViewableWeight();
464:
465: /**
466: * Set the viewable size factor of the total width betweem the source tree
467: * view and the mapper when the mapper first show up to the screen.
468: *
469: * @param sourceTreeWeight the source tree viewable size weight
470: */
471: public void setInitialSourceTreeViewableWeight(
472: float sourceTreeWeight);
473:
474: /**
475: * Close this mapper, release any system resource.
476: */
477: public void close();
478:
479: /**
480: * Set the factory which handles setting up literal info on
481: * field objects created from the palette.
482: */
483: public void setLiteralUpdaterFactory(
484: ILiteralUpdaterFactory infoFactory);
485:
486: /**
487: * Called when the mapper detects that a field node has been set
488: * with a new literal.
489: */
490: public void updateFieldLiteral(
491: IBasicMapperLiteralUpdateEventInfo info);
492: }
|