Changeset 7301
- Timestamp:
- 04/27/08 16:35:31 (5 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/jsnyder/ComponentProject/src/edu/vt/ossie/editors/OWDEditor.java
r7295 r7301 19 19 import org.eclipse.ui.PlatformUI; 20 20 import org.eclipse.ui.part.EditorPart; 21 import org.eclipse.ui.texteditor.IElementStateListener;22 21 import org.eclipse.jface.action.Action; 23 22 import org.eclipse.jface.action.IMenuListener; … … 38 37 import org.eclipse.swt.widgets.Label; 39 38 import org.eclipse.swt.widgets.Shell; 40 import org.eclipse.swt.widgets.Text;41 39 import org.eclipse.swt.widgets.Tree; 42 40 import org.python.core.Py; 43 41 import org.python.core.PyList; 44 import org.python.core.PyObject;45 42 import edu.vt.ossie.OWDPlugin; 46 43 import edu.vt.ossie.jyinterface.interfaces.MainFrame; … … 48 45 import edu.vt.ossie.views.ResourceTreeLabelProvider; 49 46 import edu.vt.ossie.views.ResourceTreeContentProvider.TreeNode; 47 import edu.vt.ossie.wavedev.*; 50 48 51 49 public class OWDEditor … … 107 105 public void widgetSelected(SelectionEvent event) 108 106 { 109 System.out.println("button pressed"); 110 PyList results = mainFrame().loadResources(); 111 availableResourcesTreeViewer.setInput(results); 107 refreshResources(); 112 108 } 113 109 }); … … 122 118 availableResourcesTreeViewer.setLabelProvider( 123 119 new ResourceTreeLabelProvider()); 124 availableResourcesTreeViewer.setInput(125 mainFrame().loadResources());126 127 final Action addToWaveform = new Action("Add to Waveform")128 {129 };130 120 131 121 final Action addToNode = new Action("Add to Node") … … 156 146 if (!node.hasChildren()) 157 147 { 158 159 mgr.add(new AddToWaveformAction(node.data())); 160 mgr.add(addToNode); 161 mgr.add(addToPlatform); 148 if ("Components".equals( 149 node.parent().getName())) 150 { 151 mgr.add(new AddToWaveformAction( 152 node.data())); 153 } 154 else if ("Devices".equals( 155 node.parent().getName())) 156 { 157 mgr.add(addToNode); 158 } 159 else if ("Nodes".equals( 160 node.parent().getName())) 161 { 162 mgr.add(addToPlatform); 163 } 162 164 mgr.add(new DoxygenAction(node.data())); 163 165 } … … 182 184 } 183 185 { 184 activeWaveformTree = new Tree(mainWindow, SWT. NONE);186 activeWaveformTree = new Tree(mainWindow, SWT.BORDER); 185 187 activeWaveformTree.setBounds(257, 30, 490, 149); 186 188 activeWaveformTreeViewer = new TreeViewer(activeWaveformTree); 187 189 activeWaveformTreeViewer.setContentProvider(new ResourceTreeContentProvider()); 188 190 activeWaveformTreeViewer.setLabelProvider(new ResourceTreeLabelProvider()); 189 191 190 192 } 191 193 { … … 200 202 scroller.setMinSize(mainWindow.computeSize(SWT.DEFAULT, SWT.DEFAULT)); 201 203 scroller.setContent(mainWindow); 204 205 // Load the trees 206 refreshResources(); 207 refreshWaveform(); 208 refreshPlatform(); 202 209 } 203 210 … … 302 309 303 310 // ---------------------------------------------------------- 304 public PyObject getActiveWavefrom() 305 { 306 if(activeWaveform == null) 307 activeWaveform = mainFrame().getActiveWaveform(); 311 public void refreshResources() 312 { 313 System.out.println("Refreshing resources tree"); 314 availableResourcesTreeViewer.setInput( 315 wavedevFactory().toArrayOfWrappedElements( 316 mainFrame().loadResources())); 317 } 318 319 320 // ---------------------------------------------------------- 321 public Waveform getActiveWaveform() 322 { 323 if (activeWaveform == null) 324 { 325 activeWaveform = (Waveform)wavedevFactory() 326 .wrap(mainFrame().getActiveWaveform()); 327 } 308 328 return activeWaveform; 309 329 } … … 311 331 312 332 // ---------------------------------------------------------- 313 public PyObject getActivePlatform() 314 { 315 if(activePlatform == null) 316 activePlatform = mainFrame().getActivePlatform(); 333 public void refreshWaveform() 334 { 335 System.out.println("Refreshing waveform tree"); 336 activeWaveformTreeViewer.setInput(getActiveWaveform()); 337 } 338 339 340 // ---------------------------------------------------------- 341 public PyWrapper getActivePlatform() 342 { 343 if (activePlatform == null) 344 { 345 activePlatform = wavedevFactory().wrap( 346 mainFrame.getActivePlatform()); 347 } 317 348 return activePlatform; 349 } 350 351 352 // ---------------------------------------------------------- 353 public void refreshPlatform() 354 { 355 System.out.println("Refreshing platform tree"); 356 // deployedNodesTreeViewer.setInput(getActivePlatform()); 318 357 } 319 358 … … 401 440 System.out.println("OWDEditor: loading file " + fileName); 402 441 mainFrame().loadProject(Py.newString(fileName)); 442 activeWaveform = null; 443 activePlatform = null; 403 444 initializeTitle(input); 404 445 } … … 460 501 461 502 // ---------------------------------------------------------- 503 private Factory wavedevFactory() 504 { 505 if (wavedevFactory == null) 506 { 507 wavedevFactory = new Factory(OWDPlugin.getInterpreter()); 508 } 509 return wavedevFactory; 510 } 511 512 513 514 // ---------------------------------------------------------- 462 515 private static abstract class ComponentAction 463 516 extends Action 464 517 { 465 518 // ---------------------------------------------------------- 466 public ComponentAction(String name, Py Objectsubject)519 public ComponentAction(String name, PyWrapper subject) 467 520 { 468 521 super(name); … … 470 523 } 471 524 472 protected Py Objectsubject;525 protected PyWrapper subject; 473 526 } 474 527 … … 479 532 { 480 533 // ---------------------------------------------------------- 481 public DoxygenAction(Py Objectsubject)534 public DoxygenAction(PyWrapper subject) 482 535 { 483 536 super("Display Doxygen", subject); … … 488 541 public void run() 489 542 { 490 mainFrame().displayDoxygen(subject );491 } 492 } 493 543 mainFrame().displayDoxygen(subject.pyObject()); 544 } 545 } 546 494 547 private class AddToWaveformAction 495 548 extends ComponentAction 496 549 { 497 550 498 public AddToWaveformAction(Py Object subject)551 public AddToWaveformAction(PyWrapper subject) 499 552 { 500 553 super("Add to Waveform", subject); 501 554 // TODO Auto-generated constructor stub 502 555 } 503 556 504 557 public void run() 505 558 { 506 559 System.out.println("here"); 507 mainFrame.addComponentToActiveWaveform(subject); 508 activeWaveformTreeViewer.setInput(mainFrame.getActiveWaveform()); 509 560 mainFrame.addComponentToActiveWaveform(subject.pyObject()); 561 refreshWaveform(); 510 562 } 511 563 512 564 } 513 565 … … 558 610 559 611 private MainFrame mainFrame; 560 private PyObjectactiveWaveform;561 private Py ObjectactivePlatform;612 private Waveform activeWaveform; 613 private PyWrapper activePlatform; 562 614 private Image titleImage; 615 private Factory wavedevFactory; 563 616 }