use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.
the class JavaFieldBreakpointType method addBreakpoint.
@Nullable
@Override
public XLineBreakpoint<JavaFieldBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
final Ref<XLineBreakpoint<JavaFieldBreakpointProperties>> result = Ref.create(null);
AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
protected boolean validateData() {
final String className = getClassName();
if (className.length() == 0) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"), DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
return false;
}
final String fieldName = getFieldName();
if (fieldName.length() == 0) {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"), DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
return false;
}
PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
if (psiClass != null) {
final PsiFile psiFile = psiClass.getContainingFile();
Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
if (document != null) {
PsiField field = psiClass.findFieldByName(fieldName, true);
if (field != null) {
final int line = document.getLineNumber(field.getTextOffset());
ApplicationManager.getApplication().runWriteAction(() -> {
XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager().addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName, className));
result.set(fieldBreakpoint);
});
return true;
} else {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
}
}
} else {
Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
}
return false;
}
};
dialog.show();
return result.get();
}
use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.
the class XBreakpointActionsPanel method saveProperties.
@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();
}
}
use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.
the class XBreakpointActionsPanel method init.
public void init(Project project, XBreakpointManager breakpointManager, @NotNull XBreakpointBase 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(), true);
JComponent logExpressionComponent = myLogExpressionComboBox.getComponent();
myLogExpressionPanel.add(logExpressionComponent, BorderLayout.CENTER);
myLogExpressionComboBox.setEnabled(false);
boolean isLineBreakpoint = breakpoint instanceof XLineBreakpoint;
myTemporaryCheckBox.setVisible(isLineBreakpoint);
if (isLineBreakpoint) {
myTemporaryCheckBox.addActionListener(e -> ((XLineBreakpoint) myBreakpoint).setTemporary(myTemporaryCheckBox.isSelected()));
}
myLogExpressionCheckBox.addActionListener(listener);
DebuggerUIUtil.focusEditorOnCheck(myLogExpressionCheckBox, myLogExpressionComboBox.getEditorComponent());
} else {
myExpressionPanel.getParent().remove(myExpressionPanel);
}
}
use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.
the class XBreakpointActionsPanel method loadProperties.
@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();
}
use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.
the class XBreakpointFileGroupingRule method getGroup.
public XBreakpointFileGroup getGroup(@NotNull final B breakpoint, @NotNull final Collection<XBreakpointFileGroup> groups) {
if (!(breakpoint instanceof XLineBreakpoint)) {
return null;
}
XSourcePosition position = ((XLineBreakpoint) breakpoint).getSourcePosition();
if (position == null)
return null;
VirtualFile file = position.getFile();
for (XBreakpointFileGroup group : groups) {
if (group.getFile().equals(file)) {
return group;
}
}
return new XBreakpointFileGroup(file);
}
Aggregations