| /* |
| * Copyright 2000-2011 JetBrains s.r.o. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| package com.intellij.xdebugger.impl.breakpoints.ui; |
| |
| import com.intellij.openapi.project.Project; |
| import com.intellij.xdebugger.XExpression; |
| import com.intellij.xdebugger.breakpoints.XBreakpointManager; |
| import com.intellij.xdebugger.breakpoints.XLineBreakpoint; |
| import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; |
| import com.intellij.xdebugger.impl.XDebuggerUtilImpl; |
| import com.intellij.xdebugger.impl.breakpoints.XBreakpointBase; |
| import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; |
| import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox; |
| import org.jetbrains.annotations.NotNull; |
| import org.jetbrains.annotations.Nullable; |
| |
| import javax.swing.*; |
| import java.awt.*; |
| import java.awt.event.ActionEvent; |
| import java.awt.event.ActionListener; |
| |
| /** |
| * Created by IntelliJ IDEA. |
| * User: zajac |
| * Date: 18.06.11 |
| * Time: 9:45 |
| * To change this template use File | Settings | File Templates. |
| */ |
| public class XBreakpointActionsPanel<B extends XBreakpointBase<?,?,?>> extends XBreakpointPropertiesSubPanel<B> { |
| public static final String LOG_EXPRESSION_HISTORY_ID = "breakpointLogExpression"; |
| |
| private JCheckBox myLogMessageCheckBox; |
| private JCheckBox myLogExpressionCheckBox; |
| private JPanel myLogExpressionPanel; |
| private JPanel myContentPane; |
| private JPanel myMainPanel; |
| private JCheckBox myTemporaryCheckBox; |
| private XDebuggerExpressionComboBox myLogExpressionComboBox; |
| |
| public void init(Project project, XBreakpointManager breakpointManager, @NotNull B breakpoint, @Nullable XDebuggerEditorsProvider debuggerEditorsProvider) { |
| init(project, breakpointManager, breakpoint); |
| if (debuggerEditorsProvider != null) { |
| ActionListener listener = new ActionListener() { |
| public void actionPerformed(final ActionEvent e) { |
| onCheckboxChanged(); |
| } |
| }; |
| myLogExpressionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, LOG_EXPRESSION_HISTORY_ID, myBreakpoint.getSourcePosition()); |
| JComponent logExpressionComponent = myLogExpressionComboBox.getComponent(); |
| myLogExpressionPanel.add(logExpressionComponent, BorderLayout.CENTER); |
| myLogExpressionComboBox.setEnabled(false); |
| myTemporaryCheckBox.setVisible(breakpoint instanceof XLineBreakpoint); |
| myLogExpressionCheckBox.addActionListener(listener); |
| DebuggerUIUtil.focusEditorOnCheck(myLogExpressionCheckBox, myLogExpressionComboBox.getEditorComponent()); |
| } |
| else { |
| myLogExpressionCheckBox.setVisible(false); |
| } |
| } |
| |
| @Override |
| public boolean lightVariant(boolean showAllOptions) { |
| if (!showAllOptions && !myBreakpoint.isLogMessage() && myBreakpoint.getLogExpression() == null && |
| (!(myBreakpoint instanceof XLineBreakpoint) || !((XLineBreakpoint)myBreakpoint).isTemporary()) ) { |
| myMainPanel.setVisible(false); |
| return true; |
| } else { |
| myMainPanel.setBorder(null); |
| return false; |
| } |
| } |
| |
| private void onCheckboxChanged() { |
| if (myLogExpressionComboBox != null) { |
| myLogExpressionComboBox.setEnabled(myLogExpressionCheckBox.isSelected()); |
| } |
| } |
| |
| @Override |
| void loadProperties() { |
| myLogMessageCheckBox.setSelected(myBreakpoint.isLogMessage()); |
| |
| if (myBreakpoint instanceof XLineBreakpoint) { |
| myTemporaryCheckBox.setSelected(((XLineBreakpoint)myBreakpoint).isTemporary()); |
| } |
| |
| if (myLogExpressionComboBox != null) { |
| XExpression logExpression = myBreakpoint.getLogExpressionObjectInt(); |
| myLogExpressionComboBox.setExpression(logExpression); |
| myLogExpressionCheckBox.setSelected(myBreakpoint.isLogExpressionEnabled() && logExpression != null); |
| } |
| onCheckboxChanged(); |
| } |
| |
| @Override |
| void saveProperties() { |
| myBreakpoint.setLogMessage(myLogMessageCheckBox.isSelected()); |
| |
| if (myBreakpoint instanceof XLineBreakpoint) { |
| ((XLineBreakpoint)myBreakpoint).setTemporary(myTemporaryCheckBox.isSelected()); |
| } |
| |
| if (myLogExpressionComboBox != null) { |
| XExpression expression = myLogExpressionComboBox.getExpression(); |
| XExpression logExpression = !XDebuggerUtilImpl.isEmptyExpression(expression) ? expression : null; |
| myBreakpoint.setLogExpressionEnabled(logExpression == null || myLogExpressionCheckBox.isSelected()); |
| myBreakpoint.setLogExpressionObject(logExpression); |
| myLogExpressionComboBox.saveTextInHistory(); |
| } |
| } |
| |
| JComponent getDefaultFocusComponent() { |
| if (myLogExpressionComboBox != null && myLogExpressionComboBox.getComboBox().isEnabled()) { |
| return myLogExpressionComboBox.getEditorComponent(); |
| } |
| return null; |
| } |
| |
| public void dispose() { |
| } |
| } |