1 56 57 package org.objectstyle.cayenne.modeler.editor; 58 59 import java.awt.Component ; 60 61 import javax.swing.JScrollPane ; 62 import javax.swing.JTabbedPane ; 63 import javax.swing.event.ChangeEvent ; 64 import javax.swing.event.ChangeListener ; 65 66 import org.objectstyle.cayenne.map.ProcedureParameter; 67 import org.objectstyle.cayenne.modeler.Application; 68 import org.objectstyle.cayenne.modeler.ProjectController; 69 import org.objectstyle.cayenne.modeler.action.RemoveProcedureParameterAction; 70 import org.objectstyle.cayenne.modeler.event.ProcedureDisplayEvent; 71 import org.objectstyle.cayenne.modeler.event.ProcedureDisplayListener; 72 import org.objectstyle.cayenne.modeler.event.ProcedureParameterDisplayEvent; 73 import org.objectstyle.cayenne.modeler.event.ProcedureParameterDisplayListener; 74 75 80 public class ProcedureTabbedView 81 extends JTabbedPane 82 implements ProcedureDisplayListener, ProcedureParameterDisplayListener { 83 84 protected ProjectController eventController; 85 protected ProcedureTab procedurePanel; 86 protected ProcedureParameterTab procedureParameterPanel; 87 88 public ProcedureTabbedView(ProjectController eventController) { 89 this.eventController = eventController; 90 91 setTabPlacement(JTabbedPane.TOP); 93 procedurePanel = new ProcedureTab(eventController); 94 addTab("Procedure", new JScrollPane (procedurePanel)); 95 procedureParameterPanel = new ProcedureParameterTab(eventController); 96 addTab("Parameters", procedureParameterPanel); 97 98 eventController.addProcedureDisplayListener(this); 100 eventController.addProcedureParameterDisplayListener(this); 101 this.addChangeListener(new ChangeListener () { 102 public void stateChanged(ChangeEvent e) { 103 Component selected = ProcedureTabbedView.this.getSelectedComponent(); 105 while (selected instanceof JScrollPane ) { 106 selected = ((JScrollPane ) selected).getViewport().getView(); 107 } 108 109 ((ExistingSelectionProcessor) selected).processExistingSelection(e); 110 } 111 }); 112 } 113 114 117 public void currentProcedureChanged(ProcedureDisplayEvent e) { 118 Application.getInstance().getAction(RemoveProcedureParameterAction.getActionName()).setEnabled(false); 119 120 if (e.getProcedure() == null) 121 setVisible(false); 122 else { 123 if (e.isTabReset()) { 124 this.setSelectedIndex(0); 125 } 126 this.setVisible(true); 127 } 128 } 129 130 public void currentProcedureParameterChanged(ProcedureParameterDisplayEvent e) { 131 if (e.getProcedureParameter() == null) 132 return; 133 134 ProcedureParameter parameter = e.getProcedureParameter(); 135 procedureParameterPanel.selectParameter(parameter); 136 } 137 138 } 139 | Popular Tags |