junichi11 commented on code in PR #6366: URL: https://github.com/apache/netbeans/pull/6366#discussion_r1308107545
########## php/php.dbgp/src/org/netbeans/modules/php/dbgp/ui/DbgpExceptionBreakpointPanel.java: ########## @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.netbeans.modules.php.dbgp.ui; + +import javax.swing.JComponent; +import javax.swing.JEditorPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import org.netbeans.api.debugger.DebuggerManager; +import org.netbeans.editor.Utilities; +import org.netbeans.modules.php.dbgp.breakpoints.ExceptionBreakpoint; +import org.netbeans.modules.php.dbgp.ui.completion.ExceptionClassNbDebugEditorKit; +import org.netbeans.spi.debugger.ui.Controller; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.util.NbBundle; +import org.openide.util.Pair; + [email protected]({ + "DbgpExceptionBreakpointPanel.EmptyExceptionName=Please enter non-empty exception name.", +}) +public class DbgpExceptionBreakpointPanel extends JPanel implements Controller { + private static final long serialVersionUID = 4967178020173186468L; + + private final JEditorPane classNameEditorPane; + private final JScrollPane classNameScrollPane; + + public DbgpExceptionBreakpointPanel() { + initComponents(); + Pair<JScrollPane, JEditorPane> codeCompletionEditor = addClassNameEditorCC(ExceptionClassNbDebugEditorKit.MIME_TYPE, classNameEditorPanel, "", ""); // NOI18N + classNameScrollPane = codeCompletionEditor.first(); + classNameEditorPane = codeCompletionEditor.second(); + classNameEditorPane.getAccessibleContext().setAccessibleName("class name editor pane"); // NOI18N + classNameEditorPane.getAccessibleContext().setAccessibleDescription("class name editor pane for exception name"); // NOI18N + exceptionLabel.setLabelFor(classNameScrollPane); + } + + @Override + public boolean cancel() { + return true; + } + + @Override + public boolean ok() { + String exceptionName = classNameEditorPane.getText(); + if (exceptionName == null || exceptionName.trim().length() == 0) { + String msg = Bundle.DbgpExceptionBreakpointPanel_EmptyExceptionName(); + NotifyDescriptor descr = new NotifyDescriptor.Message(msg); + DialogDisplayer.getDefault().notify(descr); + return false; + } + ExceptionBreakpoint breakpoint = new ExceptionBreakpoint(exceptionName); + DebuggerManager.getDebuggerManager().addBreakpoint(breakpoint); + return true; + } + + static Pair<JScrollPane, JEditorPane> addClassNameEditorCC(String mimeType, JComponent comp, String className, String tooltipText) { + JComponent [] editorComponents = Utilities.createSingleLineEditor(mimeType); + JScrollPane scrollPane = (JScrollPane) editorComponents[0]; + JEditorPane editorPane = (JEditorPane) editorComponents[1]; + editorPane.setText(className); + if (comp != null) { + java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); + comp.add(scrollPane, gridBagConstraints); + } + scrollPane.setToolTipText(tooltipText); + editorPane.setToolTipText(tooltipText); + return Pair.<JScrollPane, JEditorPane>of(scrollPane, editorPane); + } Review Comment: ```suggestion private Pair<JScrollPane, JEditorPane> createCodeCompletionEditor() { JComponent [] editorComponents = Utilities.createSingleLineEditor(ExceptionClassNbDebugEditorKit.MIME_TYPE); JScrollPane scrollPane = (JScrollPane) editorComponents[0]; JEditorPane editorPane = (JEditorPane) editorComponents[1]; initClassNameEditorPanel(scrollPane); editorPane.setText(""); // NOI18N scrollPane.setToolTipText(""); // NOI18N editorPane.setToolTipText(""); // NOI18N return Pair.<JScrollPane, JEditorPane>of(scrollPane, editorPane); } private void initClassNameEditorPanel(JScrollPane scrollPane) { java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3); classNameEditorPanel.add(scrollPane, gridBagConstraints); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
