1 19 package org.netbeans.modules.db.sql.visualeditor.querybuilder; 20 21 import javax.swing.JViewport ; 22 import javax.swing.JPanel ; 23 import javax.swing.JComponent ; 24 import javax.swing.JFrame ; 25 import javax.swing.JDialog ; 26 import javax.swing.JSplitPane ; 27 import javax.swing.JScrollPane ; 28 import javax.swing.JButton ; 29 import javax.swing.JLabel ; 30 import javax.swing.BorderFactory ; 31 32 import javax.swing.table.DefaultTableModel ; 33 34 import javax.swing.event.*; 35 36 import java.util.Hashtable ; 37 38 import java.awt.Rectangle ; 39 import java.awt.Color ; 40 import java.awt.Dimension ; 41 import java.awt.GridLayout ; 42 import java.awt.GridBagLayout ; 43 import java.awt.GridBagConstraints ; 44 import java.awt.Font ; 45 import java.awt.event.*; 46 47 import org.openide.util.NbBundle; 48 49 import org.openide.ErrorManager; 50 import org.openide.NotifyDescriptor; 51 import org.openide.DialogDisplayer; 52 53 import org.netbeans.modules.db.sql.visualeditor.Log; 54 55 59 public class QueryBuilderPane extends JSplitPane { 60 61 63 private boolean DEBUG = false; 64 65 private int DIVIDER_SIZE = 7; 66 67 70 private QueryBuilderResultTable _queryBuilderResultTable; 71 private QueryBuilderGraphFrame _queryBuilderGraphFrame; 72 private QueryBuilderInputTable _queryBuilderInputTable; 73 private QueryBuilderSqlTextArea _queryBuilderSqlTextArea; 74 75 private QueryBuilder _queryBuilder; 76 77 private JLabel qbitLabel; 78 private JLabel qbstaLabel; 79 private JLabel qbgfLabel; 80 81 private boolean graphScrollPaneEnabled; 84 private boolean qbInputTableSPEnabled; 85 86 private JScrollPane graphScrollPane; 87 private JScrollPane qbInputTableSP; 88 89 private JPanel bottomPanel; 90 private JPanel buttonPanel; 91 private boolean _keyTyped = false; 92 93 94 96 public QueryBuilderPane(QueryBuilder queryBuilder) 97 { 98 99 117 118 super(JSplitPane.VERTICAL_SPLIT); 119 Log.err.log(ErrorManager.INFORMATIONAL, "Entering QueryBuilderPane ctor"); 121 _queryBuilder = queryBuilder; 122 123 graphScrollPaneEnabled = true; 124 qbInputTableSPEnabled = true; 125 126 JFrame.setDefaultLookAndFeelDecorated(true); 128 JDialog.setDefaultLookAndFeelDecorated(true); 129 130 132 _queryBuilderInputTable = new QueryBuilderInputTable(_queryBuilder); 133 _queryBuilderInputTable.setFocusable ( true ); 134 _queryBuilderInputTable.getAccessibleContext().setAccessibleName( 135 NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBIT_a11yName")); 136 _queryBuilderInputTable.getAccessibleContext().setAccessibleDescription( 137 NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBIT_a11yDescription")); 138 qbitLabel = new JLabel (); 139 qbitLabel.setText(NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBIT_label")); 140 qbitLabel.setLabelFor(_queryBuilderInputTable); 141 142 _queryBuilderSqlTextArea = new QueryBuilderSqlTextArea(_queryBuilder); 143 _queryBuilderSqlTextArea.setFocusable ( true ); 144 _queryBuilderSqlTextArea.getAccessibleContext().setAccessibleName( 145 NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBSTA_a11yName")); 146 _queryBuilderSqlTextArea.getAccessibleContext().setAccessibleDescription( 147 NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBSTA_a11yDescription")); 148 qbstaLabel = new JLabel (); 149 qbstaLabel.setText(NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBSTA_label")); 150 qbstaLabel.setLabelFor(_queryBuilderSqlTextArea); 151 152 _queryBuilderResultTable = new QueryBuilderResultTable(_queryBuilder); 153 _queryBuilderResultTable.setFocusable ( true ); 154 155 _queryBuilderGraphFrame = new QueryBuilderGraphFrame( 159 _queryBuilder, 160 _queryBuilderInputTable, 161 _queryBuilderSqlTextArea, 162 (DefaultTableModel ) _queryBuilderResultTable.getModel() 163 ); 164 _queryBuilderGraphFrame.setFocusable ( true ); 165 _queryBuilderGraphFrame.getAccessibleContext().setAccessibleName( 166 NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBGF_a11yName")); 167 _queryBuilderGraphFrame.getAccessibleContext().setAccessibleDescription( 168 NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBGF_a11yDescription")); 169 qbgfLabel = new JLabel (); 170 qbgfLabel.setText(NbBundle.getMessage(QueryBuilderPane.class, "QBP_QBGF_label")); 171 qbgfLabel.setLabelFor(_queryBuilderGraphFrame); 172 173 graphScrollPane = new JScrollPane (_queryBuilderGraphFrame); 176 graphScrollPane.setMinimumSize ( new java.awt.Dimension ( this.getWidth(), 40 ) ); 177 this.setTopComponent(graphScrollPane); 178 179 JSplitPane firstSplitPane = new JSplitPane (JSplitPane.VERTICAL_SPLIT); 180 JSplitPane secondSplitPane = new JSplitPane (JSplitPane.VERTICAL_SPLIT); 181 182 bottomPanel = new JPanel (); 185 GridBagLayout gridbag = new GridBagLayout (); 186 GridBagConstraints c = new GridBagConstraints (); 187 c.gridwidth = 1; 188 c.gridheight = 1; 189 c.weightx = 1; 190 c.weighty = 1; 191 c.fill = GridBagConstraints.BOTH; 192 193 bottomPanel.setLayout(gridbag); 194 195 qbInputTableSP = new JScrollPane (_queryBuilderInputTable, 197 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 198 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 199 qbInputTableSP.getViewport().setBackground(Color.white); 200 qbInputTableSP.setMinimumSize ( new java.awt.Dimension ( this.getWidth(), 40 ) ); 201 c.gridx = 0; 202 c.gridy = 0; 203 gridbag.setConstraints(qbInputTableSP, c); 204 205 207 208 JScrollPane qbSqlTextAreaSP = new JScrollPane (_queryBuilderSqlTextArea, 210 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 211 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 212 c.gridx = 0; 213 c.gridy = 1; 214 gridbag.setConstraints(qbSqlTextAreaSP, c); 215 qbSqlTextAreaSP.setMinimumSize ( new java.awt.Dimension ( this.getWidth(), 40 ) ); 216 218 JScrollPane qbResultTableSP = new JScrollPane (_queryBuilderResultTable, 220 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 221 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 222 qbResultTableSP.getViewport().setBackground(Color.white); 223 qbResultTableSP.setMinimumSize ( new java.awt.Dimension ( this.getWidth(), 40 ) ); 224 c.gridx = 0; 225 c.gridy = 3; 226 gridbag.setConstraints(qbResultTableSP, c); 227 228 firstSplitPane.setTopComponent ( qbSqlTextAreaSP ); 229 firstSplitPane.setBottomComponent ( qbResultTableSP ); 230 firstSplitPane.setDividerSize(DIVIDER_SIZE); 231 firstSplitPane.setOneTouchExpandable(true); 232 firstSplitPane.setResizeWeight(0.5); 233 234 secondSplitPane.setTopComponent ( qbInputTableSP ); 235 secondSplitPane.setBottomComponent ( firstSplitPane ); 236 secondSplitPane.setDividerSize(DIVIDER_SIZE); 237 secondSplitPane.setOneTouchExpandable(true); 238 secondSplitPane.setResizeWeight(0.5); 239 240 this.setBottomComponent(secondSplitPane); 241 this.setDividerSize(DIVIDER_SIZE); 242 this.setResizeWeight(0.5); 243 this.setOneTouchExpandable(true); 244 this.setVisible(true); 245 } 246 247 248 251 String getSqlTextAreaText() 252 { 253 return _queryBuilderSqlTextArea.getText(); 254 } 255 256 259 QueryBuilderResultTable getQueryBuilderResultTable() 260 { 261 return _queryBuilderResultTable; 262 } 263 264 267 QueryBuilderGraphFrame getQueryBuilderGraphFrame() 268 { 269 return _queryBuilderGraphFrame; 270 } 271 272 275 QueryBuilderInputTable getQueryBuilderInputTable() 276 { 277 return _queryBuilderInputTable; 278 } 279 282 QueryBuilderSqlTextArea getQueryBuilderSqlTextArea() 283 { 284 return _queryBuilderSqlTextArea; 285 } 286 287 290 void clear() 291 { 292 _queryBuilderInputTable.clearModel(); 293 _queryBuilderSqlTextArea.clear(); 294 _queryBuilderResultTable.clearModel(); 295 _queryBuilderGraphFrame.clearGraph(); 296 } 297 298 301 public void setEnableContainer ( java.awt.Container c , boolean value ) { 302 java.awt.Component [] components = c.getComponents(); 303 for(int i=0; i<components.length; i++) { 304 components[i].setEnabled(value); 305 if(components[i] instanceof java.awt.Container ) { 306 setEnableContainer((java.awt.Container )components[i], value); 307 } 308 } 309 } 310 311 316 326 327 332 public void setQueryBuilderInputTableEnabled ( boolean value ) { 333 if ( qbInputTableSPEnabled == value ) return; 334 if ( qbInputTableSP != null ) { 335 setEnableContainer ( qbInputTableSP , value ); 336 qbInputTableSPEnabled = value ; 337 } 338 } 339 } 340 | Popular Tags |