bitbucket-19: show text/x-javahints editor (including errors) in the Apply Pattern dialog.
1.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.form Wed Jul 20 18:31:35 2011 +0200
1.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.form Thu Jul 21 15:57:25 2011 +0200
1.3 @@ -1,4 +1,4 @@
1.4 -<?xml version="1.1" encoding="UTF-8" ?>
1.5 +<?xml version="1.0" encoding="UTF-8" ?>
1.6
1.7 <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
1.8 <NonVisualComponents>
1.9 @@ -221,22 +221,6 @@
1.10
1.11 <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
1.12 <SubComponents>
1.13 - <Container class="javax.swing.JScrollPane" name="jScrollPane1">
1.14 - <AuxValues>
1.15 - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
1.16 - </AuxValues>
1.17 - <Constraints>
1.18 - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
1.19 - <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
1.20 - </Constraint>
1.21 - </Constraints>
1.22 -
1.23 - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
1.24 - <SubComponents>
1.25 - <Component class="javax.swing.JTextPane" name="pattern">
1.26 - </Component>
1.27 - </SubComponents>
1.28 - </Container>
1.29 <Container class="javax.swing.JPanel" name="jPanel3">
1.30 <Constraints>
1.31 <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
1.32 @@ -286,6 +270,22 @@
1.33 </Component>
1.34 </SubComponents>
1.35 </Container>
1.36 + <Container class="javax.swing.JScrollPane" name="jScrollPane4">
1.37 + <AuxValues>
1.38 + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
1.39 + </AuxValues>
1.40 + <Constraints>
1.41 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
1.42 + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
1.43 + </Constraint>
1.44 + </Constraints>
1.45 +
1.46 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
1.47 + <SubComponents>
1.48 + <Component class="javax.swing.JEditorPane" name="pattern">
1.49 + </Component>
1.50 + </SubComponents>
1.51 + </Container>
1.52 </SubComponents>
1.53 </Container>
1.54 </SubComponents>
2.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.java Wed Jul 20 18:31:35 2011 +0200
2.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/refactoring/FindDuplicatesRefactoringPanel.java Thu Jul 21 15:57:25 2011 +0200
2.3 @@ -40,6 +40,9 @@
2.4 package org.netbeans.modules.jackpot30.impl.refactoring;
2.5
2.6 import java.awt.CardLayout;
2.7 +import java.awt.event.KeyEvent;
2.8 +import java.awt.event.KeyListener;
2.9 +import java.io.IOException;
2.10 import java.util.Collection;
2.11 import java.util.Collections;
2.12 import java.util.EnumSet;
2.13 @@ -49,6 +52,8 @@
2.14 import java.util.Map;
2.15 import java.util.Set;
2.16 import java.util.TreeMap;
2.17 +import java.util.logging.Level;
2.18 +import java.util.logging.Logger;
2.19 import java.util.prefs.BackingStoreException;
2.20 import java.util.prefs.Preferences;
2.21 import javax.swing.DefaultListModel;
2.22 @@ -57,8 +62,10 @@
2.23 import javax.swing.event.ChangeListener;
2.24 import javax.swing.event.DocumentEvent;
2.25 import javax.swing.event.DocumentListener;
2.26 +import javax.swing.text.Document;
2.27 import org.netbeans.api.java.classpath.ClassPath;
2.28 import org.netbeans.api.java.classpath.GlobalPathRegistry;
2.29 +import org.netbeans.modules.editor.NbEditorUtilities;
2.30 import org.netbeans.modules.jackpot30.impl.examples.Example;
2.31 import org.netbeans.modules.jackpot30.impl.examples.Example.Option;
2.32 import org.netbeans.modules.jackpot30.impl.examples.LoadExamples;
2.33 @@ -66,6 +73,11 @@
2.34 import org.netbeans.modules.java.hints.jackpot.impl.Utilities;
2.35 import org.netbeans.modules.java.hints.jackpot.impl.batch.BatchSearch.Scope;
2.36 import org.netbeans.modules.java.hints.jackpot.spi.HintDescription;
2.37 +import org.openide.cookies.EditorCookie;
2.38 +import org.openide.cookies.SaveCookie;
2.39 +import org.openide.filesystems.FileObject;
2.40 +import org.openide.filesystems.FileUtil;
2.41 +import org.openide.loaders.DataObject;
2.42 import org.openide.util.Exceptions;
2.43 import org.openide.util.NbPreferences;
2.44 import org.openide.util.Union2;
2.45 @@ -114,7 +126,31 @@
2.46 }
2.47 public void changedUpdate(DocumentEvent e) {}
2.48 };
2.49 +
2.50 + try {
2.51 + FileObject dummy = FileUtil.createMemoryFileSystem().getRoot().createData("dummy.hint");
2.52 + DataObject od = DataObject.find(dummy);
2.53 + EditorCookie ec = od.getLookup().lookup(EditorCookie.class);
2.54 + Document doc = ec.openDocument();
2.55 + pattern.setContentType("text/x-javahints");
2.56 + pattern.setDocument(doc);
2.57 + } catch (Exception e) {
2.58 + Logger.getLogger(FindDuplicatesRefactoringPanel.class.getName()).log(Level.FINE, null, e);
2.59 + }
2.60 +
2.61 pattern.getDocument().addDocumentListener(dl);
2.62 + //do not close the dialog on esc:
2.63 + pattern.addKeyListener(new KeyListener() {
2.64 + public void keyTyped(KeyEvent e) {}
2.65 + public void keyPressed(KeyEvent e) {
2.66 + keyReleased(e);
2.67 + }
2.68 + public void keyReleased(KeyEvent e) {
2.69 + if (e.getKeyCode() == KeyEvent.VK_ESCAPE && e.getModifiersEx() == 0) {
2.70 + e.consume();
2.71 + }
2.72 + }
2.73 + });
2.74
2.75 if (!query) {
2.76 verify.setVisible(false);
2.77 @@ -151,11 +187,11 @@
2.78 removeHint = new javax.swing.JButton();
2.79 removeAllHints = new javax.swing.JButton();
2.80 customPatternPanel = new javax.swing.JPanel();
2.81 - jScrollPane1 = new javax.swing.JScrollPane();
2.82 - pattern = new javax.swing.JTextPane();
2.83 jPanel3 = new javax.swing.JPanel();
2.84 recentButton = new javax.swing.JButton();
2.85 examplesButton = new javax.swing.JButton();
2.86 + jScrollPane4 = new javax.swing.JScrollPane();
2.87 + pattern = new javax.swing.JEditorPane();
2.88 patternTypeSelectionPanel = new javax.swing.JPanel();
2.89 knowPatterns = new javax.swing.JRadioButton();
2.90 customPattern = new javax.swing.JRadioButton();
2.91 @@ -294,17 +330,6 @@
2.92
2.93 customPatternPanel.setLayout(new java.awt.GridBagLayout());
2.94
2.95 - jScrollPane1.setViewportView(pattern);
2.96 -
2.97 - gridBagConstraints = new java.awt.GridBagConstraints();
2.98 - gridBagConstraints.gridx = 0;
2.99 - gridBagConstraints.gridy = 1;
2.100 - gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
2.101 - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
2.102 - gridBagConstraints.weightx = 1.0;
2.103 - gridBagConstraints.weighty = 1.0;
2.104 - customPatternPanel.add(jScrollPane1, gridBagConstraints);
2.105 -
2.106 jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 5));
2.107
2.108 recentButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/jackpot30/impl/resources/recent_icon.png"))); // NOI18N
2.109 @@ -336,6 +361,17 @@
2.110 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
2.111 customPatternPanel.add(jPanel3, gridBagConstraints);
2.112
2.113 + jScrollPane4.setViewportView(pattern);
2.114 +
2.115 + gridBagConstraints = new java.awt.GridBagConstraints();
2.116 + gridBagConstraints.gridx = 0;
2.117 + gridBagConstraints.gridy = 1;
2.118 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
2.119 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
2.120 + gridBagConstraints.weightx = 1.0;
2.121 + gridBagConstraints.weighty = 1.0;
2.122 + customPatternPanel.add(jScrollPane4, gridBagConstraints);
2.123 +
2.124 patternSelection.add(customPatternPanel, "customPattern");
2.125
2.126 gridBagConstraints = new java.awt.GridBagConstraints();
2.127 @@ -612,6 +648,24 @@
2.128 return recent;
2.129 }
2.130
2.131 + @Override
2.132 + public void removeNotify() {
2.133 + super.removeNotify();
2.134 + DataObject od = NbEditorUtilities.getDataObject(pattern.getDocument());
2.135 +
2.136 + if (od != null) {
2.137 + SaveCookie sc = od.getLookup().lookup(SaveCookie.class);
2.138 +
2.139 + if (sc != null) {
2.140 + try {
2.141 + sc.save();
2.142 + } catch (IOException ex) {
2.143 + Logger.getLogger(FindDuplicatesRefactoringPanel.class.getName()).log(Level.FINE, null, ex);
2.144 + }
2.145 + }
2.146 + }
2.147 + }
2.148 +
2.149 // Variables declaration - do not modify//GEN-BEGIN:variables
2.150 private javax.swing.JButton addAllHints;
2.151 private javax.swing.JButton addHint;
2.152 @@ -623,13 +677,13 @@
2.153 private javax.swing.JPanel jPanel1;
2.154 private javax.swing.JPanel jPanel2;
2.155 private javax.swing.JPanel jPanel3;
2.156 - private javax.swing.JScrollPane jScrollPane1;
2.157 private javax.swing.JScrollPane jScrollPane2;
2.158 private javax.swing.JScrollPane jScrollPane3;
2.159 + private javax.swing.JScrollPane jScrollPane4;
2.160 private javax.swing.JRadioButton knowPatterns;
2.161 private javax.swing.JPanel knownPatternsPanel;
2.162 private javax.swing.ButtonGroup main;
2.163 - private javax.swing.JTextPane pattern;
2.164 + private javax.swing.JEditorPane pattern;
2.165 private javax.swing.JPanel patternSelection;
2.166 private javax.swing.JPanel patternTypeSelectionPanel;
2.167 private javax.swing.JButton recentButton;