KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > jsf > navigation > NavigationView


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.web.jsf.navigation;
20
21 import org.netbeans.modules.web.jsf.navigation.graph.NavigationBridgeUtilities;
22 import java.awt.BorderLayout JavaDoc;
23 import java.awt.Toolkit JavaDoc;
24 import java.awt.datatransfer.Clipboard JavaDoc;
25 import java.awt.datatransfer.DataFlavor JavaDoc;
26 import java.awt.datatransfer.Transferable JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.lang.ref.WeakReference JavaDoc;
29 import javax.swing.JComponent JavaDoc;
30 import javax.swing.JPanel JavaDoc;
31 import javax.swing.JScrollPane JavaDoc;
32 import org.openide.ErrorManager;
33 import org.openide.actions.CopyAction;
34 import org.openide.actions.CutAction;
35 import org.openide.actions.DeleteAction;
36 import org.openide.actions.PasteAction;
37 import org.openide.filesystems.FileObject;
38 import org.openide.loaders.DataObject;
39 import org.openide.loaders.DataObjectNotFoundException;
40 import org.openide.text.CloneableEditorSupport;
41 import org.openide.util.HelpCtx;
42 import org.openide.util.Lookup;
43 import org.openide.util.NbBundle;
44 import org.openide.util.actions.ActionPerformer;
45 import org.openide.util.datatransfer.ClipboardEvent;
46 import org.openide.util.datatransfer.ClipboardListener;
47 import org.openide.util.datatransfer.ExClipboard;
48 import org.openide.util.datatransfer.PasteType;
49 import org.openide.util.lookup.Lookups;
50 import org.openide.util.lookup.ProxyLookup;
51 import org.openide.windows.CloneableTopComponent;
52 import org.openide.windows.TopComponent;
53 import org.netbeans.core.spi.multiview.CloseOperationState;
54 import org.netbeans.core.spi.multiview.MultiViewElement;
55 import org.netbeans.core.spi.multiview.MultiViewElementCallback;
56 import org.netbeans.core.spi.multiview.MultiViewFactory;
57 import org.netbeans.api.project.Project;
58 import org.netbeans.modules.visualweb.project.jsf.api.JsfProjectUtils;
59 import org.netbeans.modules.visualweb.insync.ParserAnnotation;
60 import org.netbeans.modules.visualweb.insync.markup.MarkupUnit;
61 import org.netbeans.modules.visualweb.insync.models.FacesModelSet;
62 import org.netbeans.modules.web.jsf.navigation.options.NavigationSettings;
63 import org.netbeans.api.project.FileOwnerQuery;
64 import org.netbeans.api.visual.graph.GraphPinScene;
65 import org.netbeans.modules.web.jsf.navigation.graph.NavigationGraphScene;
66 import org.openide.options.SystemOption;
67 import org.netbeans.modules.web.jsf.navigation.vwmodel.NavigationModel;
68
69
70 /**
71  * This represents the Navigation View, shown when you open a JSF navigation.xml file or file
72  * section.
73  *
74  * @author Tor Norbye
75  * @author Joelle Lam
76  */

77 public class NavigationView extends TopComponent
78         implements MultiViewElement {
79     private NavigationModel navModel;
80
81     public static boolean newGraphView = true;
82 // private NavigationGraphScene navigationScene;
83
private GraphPinScene navigationScene;
84     private JComponent JavaDoc navigationGraphComponent;
85     private DataObject dataObject = null;
86
87 // private final PropertyChangeListener navigationSettingsListener = new NavigationSettingsListener(this);
88

89     private NavigationView() { // disallow
90
}
91
92     public NavigationView(FileObject fileObject) {
93         Project project = FileOwnerQuery.getOwner(fileObject);
94         try {
95             dataObject = DataObject.find(fileObject);
96         } catch (DataObjectNotFoundException ex) {
97             ErrorManager.getDefault().notify(ex);
98         }
99
100
101         if (project != null) {
102             FacesModelSet modelset = FacesModelSet.getInstance(project);
103             if(modelset != null) {
104                 navModel = (NavigationModel) modelset.getConfigModel(fileObject);
105                 if(navModel == null) {
106                     ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
107                             new NullPointerException JavaDoc("Retrieved model is null from modelSet=" + modelset)); // NOI18N
108
}
109             }else{
110                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
111                         new NullPointerException JavaDoc("Retrieved faces model set is null from project=" + project)); // NOI18N
112
}
113         }else{
114             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,
115                     new NullPointerException JavaDoc("Retrieved project is null for navigation FileObject=" + fileObject)); // NOI18N
116
}
117         initA11Y();
118     }
119     
120     private void initA11Y() {
121         getAccessibleContext().setAccessibleName(NbBundle.getMessage(NavigationView.class, "NavigationView"));
122         getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NavigationView.class,
123                 "ACSD_NavigationView"));
124     }
125     
126     /** Weak reference to the lookup. */
127     private WeakReference JavaDoc lookupWRef = new WeakReference JavaDoc(null);
128     
129     
130     public Lookup getLookup() {
131         Lookup lookup = (Lookup)lookupWRef.get();
132         
133         if (lookup == null) {
134             Lookup superLookup = super.getLookup();
135             
136             // XXX Needed in order to close the component automatically by project close.
137
DataObject dob = getDataObject();
138             lookup = new ProxyLookup(new Lookup[] {superLookup, Lookups.fixed(new Object JavaDoc[] {dob})});
139             lookupWRef = new WeakReference JavaDoc(lookup);
140         }
141         
142         return lookup;
143     }
144     
145     public void componentOpened() {
146         init();
147         javax.swing.ActionMap JavaDoc am = getActionMap();
148         
149         if ( navigationScene != null ) {
150             /* Once the component is opened, if it has any selected nodes
151              * don't forget to update the activated nodes
152              */

153 // GraphEvent graphEvent = navigationGraph.getGraphDocument().getSelectedComponents();
154

155 // updateActivatedNodes(graphEvent.getNodes());
156
}
157         
158         /* ###HACK####
159            MultiView some reason calls componentShowing first if this is the only editor opened.*/

160         if( showing ) {
161             /* It should not be showing yet so we will have to reset it. */
162             showing = false;
163             componentShowing();
164         }
165         
166         
167     }
168     
169     public void componentClosed() {
170         super.componentClosed();
171     }
172     
173     public String JavaDoc getName() {
174         return NbBundle.getMessage(NavigationView.class, "NavigationView"); // NOI18N
175
}
176     
177     /**
178      * Get Navigation Icon
179      * @return String
180      */

181     protected String JavaDoc iconResource() {
182         return "com/sun/rave/navigation/vwmodel/navigation.gif"; // NOI18N
183
}
184     
185     public HelpCtx getHelpCtx() {
186         return new HelpCtx("projrave_ui_elements_editors_about_navigation_editor");
187     }
188     
189     // FIXME You shouldn't overrid this method whis way,f(
190
// rather handle the graph as default focusable component.
191
public void requestFocus() {
192         if ( navigationGraphComponent != null ) {
193             navigationGraphComponent.requestFocus();
194         } else {
195             super.requestFocus();
196         }
197     }
198     
199     public boolean requestFocusInWindow() {
200         if ( navigationGraphComponent != null ) {
201             return navigationGraphComponent.requestFocusInWindow();
202         } else {
203             return super.requestFocusInWindow();
204         }
205     }
206     
207     public void requestVisible() {
208         if (multiViewElementCallback != null)
209             multiViewElementCallback.requestVisible();
210         else
211             super.requestVisible();
212     }
213     
214     public void requestActive() {
215         if (multiViewElementCallback != null)
216             multiViewElementCallback.requestActive();
217         else
218             super.requestActive();
219     }
220     
221     private boolean showing = false;
222     
223     public /* For testsuite
224     protected */
void componentShowing() {
225         if (showing) {
226             return;
227         }
228         showing = true;
229         
230         try {
231             navModel.sync();
232         } catch (Exception JavaDoc e) {
233             ErrorManager.getDefault().notify(e);
234         }
235         
236         initGraph(true);
237 // loadGraphPositions();
238

239     }
240     
241     public void componentHidden() {
242         
243         if (!showing) {
244             // For some reason, I'll often get componentHidden
245
// before any componentShowing events. Suppress these.
246
return;
247         }
248         showing = false;
249         
250 // navModel.removePropertyChangeListener(navigationGraph);
251

252 // saveGraphPositions();
253

254         MarkupUnit markupUnit = navModel.getMarkup();
255         if ( markupUnit != null ) {
256             markupUnit.flush();
257         }
258     }
259     
260     private boolean initialized = false;
261     
262     private void init() {
263         if (initialized) {
264             return;
265         }
266         initialized = true;
267         
268         MarkupUnit markupUnit = navModel.getMarkup();
269         
270         assert markupUnit != null;
271         
272         if (markupUnit.getState().isBusted()) {
273             System.out.println("The markup unit is invalid!");
274             System.out.println("Errors are:");
275             ParserAnnotation[] errors = markupUnit.getErrors();
276             for (int i = 0; i < errors.length; i++) {
277                 System.out.println("Next error = " + errors[i]);
278                 return;
279             }
280         }
281         //System.out.println("markupunit dom = " + dom);
282
//System.out.println("markupunit state = " + markupUnit.getState());
283

284         setLayout(new BorderLayout JavaDoc());
285         
286 // NavigationSettings navigationSettings = (NavigationSettings) SystemOption.findObject(NavigationSettings.class, true);
287
// navigationSettings.addPropertyChangeListener(navigationSettingsListener);
288
// newGraphView = navigationSettings.getUseNewGraphView();
289
initGraph(false);
290     }
291     
292 // private void setUseNewGraphView(boolean newView){
293
// newGraphView = newView;
294
// }
295
//
296
// private boolean getUseNewGraphView(){
297
// return newGraphView;
298
// }
299

300     /**
301      * Initializes the graph
302      * @param reset
303      */

304     public void initGraph(boolean reset){
305         if(reset){
306             this.removeAll();
307         }
308         navigationScene = new NavigationGraphScene();
309         
310         setDocument(reset);
311         navigationGraphComponent = navigationScene.createView();
312         JScrollPane JavaDoc scrollPane = new JScrollPane JavaDoc(navigationGraphComponent);
313         add(scrollPane, BorderLayout.CENTER); //NOI18N
314

315                 
316         invalidate();
317         validate();
318         repaint();
319     }
320     
321     private void setDocument(boolean isListening){
322         NavigationBridgeUtilities.getInstance().setDocument(navModel);
323         NavigationBridgeUtilities.getInstance().setGraphScene(navigationScene);
324 // if(isListening){
325
//// navModel.addPropertyChangeListener(navigationGraph);
326
// navModel.update();
327
// }
328
}
329     
330 // protected void saveGraphPositions() {
331
// if( navModel.getFile() != null ) {
332
// File navDataFile = new File(navModel.getFile().getParent().getPath(), ".VPData");
333
// if (navDataFile.getParentFile().exists()){
334
// try {
335
// org.w3c.dom.Document dataDocument = XMLUtil.createDocument("document", null, null, null);
336
// XMLSerializer.writeXMLTree(navigationGraph.getGraphViewController().getHelper(), dataDocument, null);
337
// XMLSerializer.writeXMLDocument(new FileOutputStream(navDataFile), dataDocument);
338
// } catch (IOException e) {
339
// e.printStackTrace(); // TODO
340
// }
341
// }
342
// }
343
// }
344

345
346     
347     // --------------------------------------------------------------------
348
// Cut, Copy, Paste, Delete support
349
// --------------------------------------------------------------------
350
// A lot of this is based on code in openide's ExplorerActions.java file
351

352     
353     /* Activates copy/cut/paste actions.
354      */

355     public void componentActivated() {
356         super.componentActivated();
357         
358         if( !navModel.equals(NavigationBridgeUtilities.getInstance().getNavigationModel())){
359             setDocument(false);
360         }
361 // navModel.addPropertyChangeListener(navigationGraph);
362
// navModel.update();
363

364         //Log.err.log("Component activated!");
365
if (cblistener == null)
366             cblistener = new CBListener();
367         Clipboard JavaDoc c = getClipboard();
368         if (c instanceof ExClipboard) {
369             ExClipboard clip = (ExClipboard)c;
370             clip.addClipboardListener(cblistener);
371         }
372         activateActions();
373     }
374     
375     /* Deactivates copy/cut/paste actions.
376      */

377     public void componentDeactivated() {
378         //StructureView.getInstance().setCurrent(null);
379
Clipboard JavaDoc c = getClipboard();
380         if (c instanceof ExClipboard) {
381             ExClipboard clip = (ExClipboard)c;
382             clip.removeClipboardListener(cblistener);
383         }
384         deactivateActions();
385         
386         // Just leave the nodes visible until some other window
387
// sets the activation - that way, the user can for example
388
// move up to the main window and not loose sight of the
389
// currently selected component
390

391 // navModel.removePropertyChangeListener(navigationGraph);
392

393     }
394     
395     /** copy action performer */
396     private ActionPerformer copyActionPerformer;
397     /** cut action performer */
398     private ActionPerformer cutActionPerformer;
399     /** delete action performer */
400     private ActionPerformer deleteActionPerformer;
401     
402     /** actions to work with */
403     private static CopyAction copy;
404     private static CutAction cut;
405     private static DeleteAction delete;
406     private static PasteAction paste;
407     
408     /**
409      * Called when this window is activated: make cut, copy, paste and delete sensitive based on
410      * whether or not anything is selected and whether the clipboard contains something we can
411      * absorb.
412      */

413     private void activateActions() {
414         
415         enableCutCopyDelete();
416         updatePasteAction();
417     }
418     
419     /**
420      * Called when the when the component is deactivated. We no longer allow our paste types to be
421      * invoked so clear it - get rid of the action performers as well.
422      */

423     private void deactivateActions() {
424         if (copyActionPerformer != null) {
425             copy.setActionPerformer(null);
426             cut.setActionPerformer(null);
427             delete.setActionPerformer(null);
428         }
429         if (paste != null) {
430             paste.setPasteTypes(null);
431         }
432     }
433     
434     /**
435      * Called when the selection is non zero and the component is active: enable cut, copy and
436      * delete
437      */

438     void enableCutCopyDelete() {
439         if (copyActionPerformer == null) {
440             
441             copy = (CopyAction) CopyAction.findObject(CopyAction.class, true);
442             cut = (CutAction) CutAction.findObject(CutAction.class, true);
443             delete = (DeleteAction) DeleteAction.findObject(DeleteAction.class, true);
444         }
445         
446         // Logic for deciding if copy is available here:
447
Object JavaDoc perf;
448         /* XXX Cut, Copy, Paste disabled for TP!
449         perf = copy.getActionPerformer();
450         if (perf != copyActionPerformer) {
451             copy.setActionPerformer (copyActionPerformer);
452         }
453         perf = cut.getActionPerformer();
454         if (perf != cutActionPerformer) {
455             cut.setActionPerformer (cutActionPerformer);
456         }
457          */

458         perf = delete.getActionPerformer();
459         if (perf != deleteActionPerformer) {
460             delete.setActionPerformer(deleteActionPerformer);
461         }
462     }
463     
464     /**
465      * Called when the selection is removed: disable copy, cut, delete
466      */

467 // void disableCutCopyDelete() {
468
// if (copyActionPerformer != null) {
469
// copy.setActionPerformer(null);
470
// cut.setActionPerformer(null);
471
// delete.setActionPerformer(null);
472
// }
473
// }
474

475     private class Paste extends PasteType {
476         public Transferable JavaDoc paste() throws IOException JavaDoc {
477             Clipboard JavaDoc clipboard = getClipboard();
478             Transferable JavaDoc trans = clipboard.getContents(this);
479             if (trans != null) {
480                 DataFlavor JavaDoc[] df = trans.getTransferDataFlavors();
481                 if (df == null) {
482                     return null;
483                 }
484                 /*
485                 Log.err.log("Supported dataflavors:");
486                 for (int i = 0; i < df.length; i++) {
487                     Log.err.log("Flavor " + i + " is " + df[i]);
488                 }
489                  */

490                 try {
491                     Object JavaDoc[] objs = (Object JavaDoc[])trans.getTransferData(df[0]);
492                     // XXX Not yet impelmented
493
//Log.err.log("TODO - paste objects! " + objs + " trans=" + trans);
494
} catch (Exception JavaDoc e) {
495                     ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
496                 }
497             }
498             return null;
499             // to clear clipboard, return ExTransferable.EMPTY instead...
500
}
501     }
502     
503     /**
504      * Updates paste action.
505      *
506      * @param path selected nodes
507      */

508     private void updatePasteAction() {
509         // XXX Cut, Copy, Paste disabled for TP!
510
boolean pasteEnabled = false;
511         if (!pasteEnabled) {
512             return;
513         }
514         
515         if (paste == null) {
516             paste = (PasteAction) PasteAction.findObject(PasteAction.class, true);
517         }
518         
519         Clipboard JavaDoc clipboard = getClipboard();
520         Transferable JavaDoc trans = clipboard.getContents(this);
521         if (trans != null) {
522             DataFlavor JavaDoc[] df = trans.getTransferDataFlavors();
523             int n = 0;
524             if (df != null) {
525                 n = df.length;
526             }
527             for (int i = 0; i < n; i++) {
528                 /*
529                 Log.err.log("Flavor " + i + " is " + df[i]);
530                 Log.err.log("mimetype is " + df[i].getMimeType());
531                  */

532                 if (df[i].getMimeType().startsWith("application/x-rave-nav-dnd;")) { // NOI18N
533
// Yes!
534
PasteType[] pasteTypes = new PasteType[] { new Paste() };
535                     paste.setPasteTypes(pasteTypes);
536                     return;
537                 }
538             }
539         }
540         paste.setPasteTypes(null);
541     }
542     
543 // /** Class which performs delete action */
544
// class DeleteActionPerformer extends Object implements ActionPerformer {
545
//
546
// /** Perform delete action. */
547
// public void performAction(SystemAction action) {
548
// // We run into deadlocks without this; !#$!@#!@ ModuleActions thread
549
// SwingUtilities.invokeLater(new Runnable() {
550
// public void run() {
551
//
552
// /* What is this for now? */
553
//// if (!newGraphView){
554
//// graph.deleteSelection();
555
//// }
556
// }
557
// }
558
// );
559
// }
560
// }
561

562 // /** Class which performs copy and cut actions */
563
// class CopyCutActionPerformer extends Object implements ActionPerformer {
564
// /** determine if adapter is used for copy or cut action. */
565
// boolean isCopy;
566
//
567
// /** Create new adapter */
568
// public CopyCutActionPerformer(boolean b) {
569
// isCopy = b;
570
// }
571
//
572
// /** Perform copy or cut action. */
573
// public void performAction(SystemAction action) {
574
// //Log.err.log("Copy/cut not yet working - no transfer to clipboard!");
575
// if (!isCopy) { // cut: we've copied, so now delete...
576
// // We run into deadlocks without this; !#$!@#!@ ModuleActions thread
577
// SwingUtilities.invokeLater(new Runnable() {
578
// public void run() {
579
// /* What is this for now? */
580
//// if (!newGraphView){
581
//// graph.deleteSelection();
582
//// }
583
// }
584
// }
585
// );
586
// }
587
// }
588
// }
589

590     /** tracker for all actions */
591     private CBListener cblistener;
592     
593     private class CBListener implements ClipboardListener {
594         /** This method is called when content of clipboard is changed.
595          * @param ev event describing the action
596          */

597         public void clipboardChanged(ClipboardEvent ev) {
598             if (!ev.isConsumed()) {
599                 updatePasteAction();
600             }
601         }
602     }
603     
604     /**
605      * If our clipboard is not found return the default system clipboard.
606      */

607     private static Clipboard JavaDoc getClipboard() {
608         Clipboard JavaDoc c = (Clipboard JavaDoc)Lookup.getDefault().lookup(Clipboard JavaDoc.class);
609         if (c == null) {
610             c = Toolkit.getDefaultToolkit().getSystemClipboard();
611         }
612         return c;
613     }
614     
615     /**
616      * Return the navModel associated with this navigation view
617      */

618     public NavigationModel getNavigationModel() {
619         return navModel;
620     }
621     
622     // #5049125 Cheating persistence, navigation view is opened using 'multi_view' hack.
623
public int getPersistenceType() {
624         return PERSISTENCE_NEVER;
625     }
626     
627 // <multiview>
628
private transient MultiViewElementCallback multiViewElementCallback;
629     
630     public CloseOperationState canCloseElement() {
631         // XXX I don't understand this yet. Copied from FormDesigner.
632
// Returns a placeholder state - to be sure our CloseHandler is called.
633
return MultiViewFactory.createUnsafeCloseState(
634                 "ID_CLOSING_NAVIGATION", // dummy ID // NOI18N
635
MultiViewFactory.NOOP_CLOSE_ACTION,
636                 MultiViewFactory.NOOP_CLOSE_ACTION);
637     }
638     
639     
640     /** XXX Accessor to NavigationEditoSupport so we don't create cyclic deps between navigation and project/navigationloader. */
641     public interface NavigationEditorSupportAccessor {
642         public void setMultiView(CloneableTopComponent multiview);
643     }
644     
645     public void setMultiViewCallback(MultiViewElementCallback callback) {
646         multiViewElementCallback = callback;
647         
648 // TODO XXX What the heck of hack is this? Why for deserialization (comes from FormDesigner).
649
// Is something like that needed here too? Is this call part of deserialization routine?
650
Project prj = navModel.getProject();
651         if(prj == null) {
652             return;
653         }
654         FileObject navigationFile = JsfProjectUtils.getNavigationFile(prj);
655         if(navigationFile == null) {
656             return;
657         }
658         try {
659             DataObject dObj = DataObject.find(navigationFile);
660             CloneableEditorSupport ces = (CloneableEditorSupport)dObj.getLookup().lookup(CloneableEditorSupport.class);
661             if(ces instanceof NavigationEditorSupportAccessor) {
662                 NavigationEditorSupportAccessor navigationEditorSupportAccessor = (NavigationEditorSupportAccessor)ces;
663                 // this is used (or misused?) to obtain the deserialized multiview
664
// topcomponent and set it to NavigationEditorSupport
665
navigationEditorSupportAccessor.setMultiView(
666                         (CloneableTopComponent)multiViewElementCallback.getTopComponent());
667             }
668         } catch(DataObjectNotFoundException dnfe) {
669             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, dnfe);
670         }
671     }
672     
673     public JComponent JavaDoc getToolbarRepresentation() {
674         // Will be someting here or not?
675
return new JPanel JavaDoc();
676     }
677     
678     public JComponent JavaDoc getVisualRepresentation() {
679         return this;
680     }
681 // </multiview>
682

683     /*
684      * NavigationGraphEventHandler uses this method to notify the TopComponent (NavigationView) that a
685      * a new selection has been made.
686      *
687      * @param graphNodes that were selected
688      */

689 // public void selectionUpdated(IGraphNode[] graphNodes) {
690
// updateActivatedNodes(graphNodes);
691
// }
692

693     /*
694      * NavigationGraphEventHandler uses this method to notify the TopComponent (NavigationView) that
695      * a link has been selected.
696      *
697      * @param navModel
698      * @param links that are selected
699      */

700 // public void selectionUpdated(NavigationModel document, IGraphLink[] graphLinks) {
701
//// updateActivatedNodes(document, graphLinks);
702
// }
703

704     /*
705      * updateActivatedNodes
706      * Using the graphlinks to graph the link and create a link node with
707      * the given navModel and link.
708      *
709      * @param navModel
710      * @param links that are selected
711      */

712 // private void updateActivatedNodes(NavigationModel document, IGraphLink[] graphLinks) {
713
// ArrayList<Node> actNodes = new ArrayList<Node>();
714
//
715
// for (IGraphLink graphLink: graphLinks ) {
716
// DataObject dOGraphPage = null;
717
// if( graphLink instanceof NavigationGraphLink ){
718
// Link link = ((NavigationGraphLink)graphLink).getLink();
719
// Page graphPage =link.getFrom();
720
// dOGraphPage = graphPage.getDataObject();
721
// if( link != null ) {
722
// LinkNode n = new LinkNode(dataObject, document, link);
723
// actNodes.add(n);
724
// }
725
// }
726
// }
727
//
728
// setActivatedNodes(actNodes.toArray(new Node[actNodes.size()]));
729
// }
730

731     /*
732      * updateActivatedNodes
733      * Using the graphNodes, retrieve the page, the dataobject, and ultimately the node to be added.
734      *
735      * @param graphNodes that were selected
736      */

737 // private void updateActivatedNodes(IGraphNode[] graphNodes ) {
738
// ArrayList<Node> actNodes = new ArrayList<Node>();
739
//
740
// for( IGraphNode graphNode: graphNodes ) {
741
// DataObject dOGraphPage = null;
742
// if( graphNode instanceof NavigationGraphNode ){
743
// Page graphPage = ((NavigationGraphNode)graphNode).getPage();
744
// if( graphPage != null && graphPage.getDataObject() != null ) {
745
//// dOGraphPage = graphPage.getDataObject();
746
//// }
747
//// if ( dOGraphPage != null ){
748
// PageNode pageNode = new PageNode(dataObject, graphPage);
749
// actNodes.add(pageNode);
750
// }
751
// }
752
// }
753
// setActivatedNodes(actNodes.toArray(new Node[actNodes.size()]));
754
// }
755

756 // /** Listens on <code>DesignerSettings</code> changes. */
757
// private static class NavigationSettingsListener implements PropertyChangeListener {
758
//
759
// private final NavigationView navigationView;
760
//
761
// public NavigationSettingsListener(NavigationView navView) {
762
// navigationView = navView;
763
// }
764
//
765
// public void propertyChange(PropertyChangeEvent evt) {
766
// if(NavigationSettings.PROP_USE_NEW_GRAPH_VIEW.equals(evt.getPropertyName())) {
767
// Boolean graphView = (Boolean) evt.getNewValue();
768
// if(graphView.booleanValue() != navigationView.getUseNewGraphView()){
769
// navigationView.setUseNewGraphView(graphView.booleanValue());
770
// SwingUtilities.invokeLater(new Runnable(){
771
// public void run(){
772
// navigationView.initGraph(true);
773
// }
774
// });
775
// }
776
// }
777
// }
778
//
779
// } // End of SettingsListener.
780

781     protected DataObject getDataObject() {
782         return dataObject;
783     }
784     
785 // public void setMultiViewCallback(MultiViewElementCallback arg0) {
786
// throw new UnsupportedOperationException("Not supported yet.");
787
// }
788

789 }
790
Popular Tags