private void adjustStates() {
   if (hit.isBeforeExecution()) {
     replacePane.setVisible(replaceCheckbox.isSelected());
     revalidate();
     repaint();
   }
 }
Exemple #2
0
 @Override
 public void processBreakpointAfterExecutionHit(ExecuteContext ctx, BreakpointHit breakpointHit) {
   BreakpointHitHandler handler = getBreakpointHitHandler();
   if (handler == null) {
     return;
   }
   long threadID = breakpointHit.getThreadID();
   synchronized (threadIDToExecuteContextMap) {
     threadIDToExecuteContextMap.put(threadID, ctx);
   }
   try {
     handler.processBreakpointAfterExecutionHit(breakpointHit);
   } finally {
     synchronized (threadIDToExecuteContextMap) {
       threadIDToExecuteContextMap.remove(threadID);
     }
     performThreadDataCleanup(threadID);
   }
 }
  public BreakpointHitEditor(
      final Debugger debugger,
      final DebuggerPane debuggerPane,
      final BreakpointHitNode breakpointHitNode) {
    super(new BorderLayout());
    setOpaque(false);
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setOpaque(false);
    JPanel breakpointHitExecutionPane = new JPanel(new GridBagLayout());
    breakpointHitExecutionPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 5));
    breakpointHitExecutionPane.setOpaque(false);
    hit = breakpointHitNode.getUserObject();
    int y = 0;
    breakpointHitExecutionPane.add(
        new JLabel("Query:"),
        new GridBagConstraints(
            0,
            y++,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    SqlTextArea sqlTextArea = new SqlTextArea();
    String sql = hit.getSQL();
    String parameterDescription = hit.getParameterDescription();
    if (parameterDescription != null) {
      sql += "\n -> " + parameterDescription;
    }
    sqlTextArea.setText(sql + "\n");
    sqlTextArea.setCaretPosition(0);
    breakpointHitExecutionPane.add(
        new RTextScrollPane(sqlTextArea),
        new GridBagConstraints(
            0,
            y++,
            1,
            1,
            1,
            1,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    if (hit.isBeforeExecution()) {
      replaceCheckbox = new JCheckBox("Replace with statement");
      replaceCheckbox.setOpaque(false);
      replaceCheckbox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              adjustStates();
            }
          });
      breakpointHitExecutionPane.add(
          replaceCheckbox,
          new GridBagConstraints(
              0,
              y++,
              1,
              1,
              0,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(5, 0, 0, 0),
              0,
              0));
      replaceTextArea = new SqlTextArea();
      replacePane = new RTextScrollPane(replaceTextArea);
      breakpointHitExecutionPane.add(
          replacePane,
          new GridBagConstraints(
              0,
              y++,
              1,
              1,
              1,
              1,
              GridBagConstraints.WEST,
              GridBagConstraints.BOTH,
              new Insets(2, 20, 0, 0),
              0,
              0));
    }
    JPanel executionTypePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    // For now, this choice is not exposed.
    executionTypePane.setVisible(hit.isBeforeExecution());
    executionTypePane.setOpaque(false);
    ButtonGroup executionTypeGroup = new ButtonGroup();

    final JRadioButton executeTypeNoneRadioButton = new JRadioButton("Execute");
    executeTypeNoneRadioButton.setOpaque(false);
    executeTypeNoneRadioButton.setSelected(true);
    executionTypeGroup.add(executeTypeNoneRadioButton);
    executionTypePane.add(executeTypeNoneRadioButton);

    final JRadioButton executeTypeBreakRadioButton = new JRadioButton("Execute and break");
    executeTypeBreakRadioButton.setOpaque(false);
    executionTypeGroup.add(executeTypeBreakRadioButton);
    executionTypePane.add(executeTypeBreakRadioButton);

    final JRadioButton executeTypeSkipRadioButton = new JRadioButton("Skip");
    executeTypeSkipRadioButton.setOpaque(false);
    executionTypeGroup.add(executeTypeSkipRadioButton);
    executionTypePane.add(executeTypeSkipRadioButton);

    final JRadioButton executeTypeFailRadioButton = new JRadioButton("Throw exception");
    executeTypeFailRadioButton.setOpaque(false);
    executionTypeGroup.add(executeTypeFailRadioButton);
    executionTypePane.add(executeTypeFailRadioButton);

    breakpointHitExecutionPane.add(
        executionTypePane,
        new GridBagConstraints(
            0,
            y++,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 0, 0),
            0,
            0));
    JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    buttonPane.setOpaque(false);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    JButton applyButton = new JButton("Proceed");
    applyButton.setOpaque(false);
    applyButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (hit.isBeforeExecution()) {
              String replacementSQL = null;
              ExecutionType type = RUN;
              if (executeTypeNoneRadioButton.isSelected()) {
                type = RUN;
                replacementSQL = replaceCheckbox.isSelected() ? replaceTextArea.getText() : null;
              } else if (executeTypeBreakRadioButton.isSelected()) {
                type = STEP;
                replacementSQL = replaceCheckbox.isSelected() ? replaceTextArea.getText() : null;
              } else if (executeTypeSkipRadioButton.isSelected()) {
                type = SKIP;
              } else if (executeTypeFailRadioButton.isSelected()) {
                type = FAIL;
              }

              hit.setExecutionType(type, replacementSQL);
            } else {
              hit.setExecutionType(RUN, null);
            }
            debuggerPane.proceedBreakpointHit(breakpointHitNode);
          }
        });
    buttonPane.add(applyButton);
    breakpointHitExecutionPane.add(
        buttonPane,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    adjustStates();
    tabbedPane.addTab("Execution", breakpointHitExecutionPane);
    tabbedPane.addTab(
        "Editor",
        new EditorsPane(
            new QueryExecutorCreator() {
              @Override
              public QueryExecutor createQueryExecutor() {
                return debugger.createBreakpointHitStatementExecutor(hit.getThreadID());
              }
            },
            false));
    add(tabbedPane);
  }