1 19 package org.netbeans.modules.refactoring.spi.impl; 20 import java.awt.Color ; 21 import java.awt.Dimension ; 22 import java.awt.GridBagConstraints ; 23 import javax.swing.ImageIcon ; 24 import javax.swing.JPanel ; 25 import org.netbeans.modules.refactoring.api.Problem; 26 import org.netbeans.modules.refactoring.spi.ui.RefactoringUI; 27 28 32 public class ErrorPanel extends javax.swing.JPanel { 33 34 private static ImageIcon fatalImage = null, nonFatalImage = null; 35 36 private RefactoringUI ui; 37 38 public ErrorPanel(RefactoringUI ui) { 39 this.ui = ui; 40 initComponents(); 41 setPreferredSize(new Dimension (510, 200)); 42 } 43 44 public ErrorPanel(Problem problem, RefactoringUI ui) { 45 this(ui); 46 setProblems(problem); 47 } 48 49 public void setProblems(Problem problem) { 50 errors.removeAll(); 51 int i = 0; 52 ProblemComponent.initButtonSize(problem); 53 boolean single = problem.getNext()==null; 54 while (problem != null) { 55 GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 56 gridBagConstraints.gridx = 0; 57 gridBagConstraints.gridy = i++; 58 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 59 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 60 gridBagConstraints.weightx = 1.0; 61 62 ProblemComponent c = new ProblemComponent(problem, ui, single); 63 errors.add(c, gridBagConstraints); 64 65 problem = problem.getNext(); 66 67 if (i%2 == 0) 68 c.setLightBackground(); 69 else 70 c.setDarkBackground(); 71 } 72 73 GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 74 gridBagConstraints.gridx = 0; 75 gridBagConstraints.gridy = i; 76 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 77 gridBagConstraints.weightx = 1.0; 78 gridBagConstraints.weighty = 1.0; 79 80 JPanel jp = new JPanel (); 81 jp.setBackground(Color.WHITE); 82 errors.add(jp, gridBagConstraints); 83 } 84 85 static ImageIcon getFatalErrorIcon() { 86 if (fatalImage == null) { 87 fatalImage = new ImageIcon (ErrorPanel.class.getResource("/org/netbeans/modules/refactoring/api/resources/error.png")); } 89 return fatalImage; 90 } 91 92 static ImageIcon getNonfatalErrorIcon() { 93 if (nonFatalImage == null) { 94 nonFatalImage = new ImageIcon (ErrorPanel.class.getResource("/org/netbeans/modules/refactoring/api/resources/warning.png")); } 96 return nonFatalImage; 97 } 98 99 104 private void initComponents() { 106 listPanel = new javax.swing.JPanel (); 107 errorLabel = new javax.swing.JLabel (); 108 listScrollPane = new javax.swing.JScrollPane (); 109 errors = new javax.swing.JPanel (); 110 explanationPanel = new javax.swing.JPanel (); 111 fatalError = new javax.swing.JLabel (); 112 nonFatalError = new javax.swing.JLabel (); 113 headLine = new javax.swing.JTextArea (); 114 115 setLayout(new java.awt.BorderLayout ()); 116 117 listPanel.setLayout(new java.awt.BorderLayout ()); 118 119 org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getBundle("org/netbeans/modules/refactoring/spi/impl/Bundle").getString("LBL_ErrorsList")); 120 listPanel.add(errorLabel, java.awt.BorderLayout.NORTH); 121 122 listScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 123 errors.setLayout(new java.awt.GridBagLayout ()); 124 125 listScrollPane.setViewportView(errors); 126 127 listPanel.add(listScrollPane, java.awt.BorderLayout.CENTER); 128 129 add(listPanel, java.awt.BorderLayout.CENTER); 130 131 explanationPanel.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.LEFT)); 132 133 fatalError.setIcon(new javax.swing.ImageIcon (getClass().getResource("/org/netbeans/modules/refactoring/api/resources/error.png"))); 134 org.openide.awt.Mnemonics.setLocalizedText(fatalError, org.openide.util.NbBundle.getBundle("org/netbeans/modules/refactoring/spi/impl/Bundle").getString("LBL_FatalError")); 135 fatalError.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 20)); 136 explanationPanel.add(fatalError); 137 138 nonFatalError.setIcon(new javax.swing.ImageIcon (getClass().getResource("/org/netbeans/modules/refactoring/api/resources/warning.png"))); 139 org.openide.awt.Mnemonics.setLocalizedText(nonFatalError, org.openide.util.NbBundle.getBundle("org/netbeans/modules/refactoring/spi/impl/Bundle").getString("LBL_NonFatalError")); 140 explanationPanel.add(nonFatalError); 141 142 add(explanationPanel, java.awt.BorderLayout.SOUTH); 143 144 headLine.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background")); 145 headLine.setEditable(false); 146 headLine.setFont(errorLabel.getFont()); 147 headLine.setLineWrap(true); 148 headLine.setText(org.openide.util.NbBundle.getBundle("org/netbeans/modules/refactoring/spi/impl/Bundle").getString("LBL_ErrorPanelDescription")); 149 headLine.setWrapStyleWord(true); 150 headLine.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 10, 1)); 151 add(headLine, java.awt.BorderLayout.NORTH); 152 headLine.getAccessibleContext().setAccessibleName(null); 153 headLine.getAccessibleContext().setAccessibleDescription(null); 154 155 } 157 158 private javax.swing.JLabel errorLabel; 160 private javax.swing.JPanel errors; 161 private javax.swing.JPanel explanationPanel; 162 private javax.swing.JLabel fatalError; 163 private javax.swing.JTextArea headLine; 164 private javax.swing.JPanel listPanel; 165 private javax.swing.JScrollPane listScrollPane; 166 private javax.swing.JLabel nonFatalError; 167 169 } 170 | Popular Tags |